Skip to content

Commit 16a22e2

Browse files
committed
bugs: don't crash when atom not found in history
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent 12029d2 commit 16a22e2

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

src/pkgdev/scripts/pkgdev_bugs.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -550,13 +550,23 @@ def output_graph_toml(self):
550550
):
551551
toml.write(f"blocks = [{node_blocks}]\n")
552552
for pkg, arches in node.pkgs:
553-
match = next(self.modified_repo.itermatch(pkg.versioned_atom))
554-
modified = datetime.fromtimestamp(match.time)
555-
match = next(self.added_repo.itermatch(pkg.versioned_atom))
556-
added = datetime.fromtimestamp(match.time)
557-
toml.write(
558-
f"# added on {added:%Y-%m-%d} (age {(datetime.today() - added).days} days), last modified on {modified:%Y-%m-%d} (age {(datetime.today() - modified).days} days)\n"
559-
)
553+
try:
554+
match = next(self.modified_repo.itermatch(pkg.versioned_atom))
555+
modified = datetime.fromtimestamp(match.time)
556+
age = (datetime.today() - modified).days
557+
modified_text = f"{modified:%Y-%m-%d} (age {age} days)"
558+
except StopIteration:
559+
modified_text = "<unknown>"
560+
561+
try:
562+
match = next(self.added_repo.itermatch(pkg.versioned_atom))
563+
added = datetime.fromtimestamp(match.time)
564+
age = (datetime.today() - added).days
565+
added_text = f"{added:%Y-%m-%d} (age {age} days)"
566+
except StopIteration:
567+
added_text = "<unknown>"
568+
569+
toml.write(f"# added on {added_text}, last modified on {modified_text}\n")
560570
keywords = ", ".join(f'"{x}"' for x in sort_keywords(arches))
561571
toml.write(f'"{pkg.versioned_atom}" = [{keywords}]\n')
562572
toml.write("\n\n")

0 commit comments

Comments
 (0)