From 16a22e29ec16f0013a94ff3f26f10b6a15626b57 Mon Sep 17 00:00:00 2001 From: Arthur Zamarin Date: Mon, 26 Feb 2024 22:48:42 +0200 Subject: bugs: don't crash when atom not found in history Signed-off-by: Arthur Zamarin --- src/pkgdev/scripts/pkgdev_bugs.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py index 86f5247..6864ba7 100644 --- a/src/pkgdev/scripts/pkgdev_bugs.py +++ b/src/pkgdev/scripts/pkgdev_bugs.py @@ -550,13 +550,23 @@ class DependencyGraph: ): toml.write(f"blocks = [{node_blocks}]\n") for pkg, arches in node.pkgs: - match = next(self.modified_repo.itermatch(pkg.versioned_atom)) - modified = datetime.fromtimestamp(match.time) - match = next(self.added_repo.itermatch(pkg.versioned_atom)) - added = datetime.fromtimestamp(match.time) - toml.write( - 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" - ) + try: + match = next(self.modified_repo.itermatch(pkg.versioned_atom)) + modified = datetime.fromtimestamp(match.time) + age = (datetime.today() - modified).days + modified_text = f"{modified:%Y-%m-%d} (age {age} days)" + except StopIteration: + modified_text = "" + + try: + match = next(self.added_repo.itermatch(pkg.versioned_atom)) + added = datetime.fromtimestamp(match.time) + age = (datetime.today() - added).days + added_text = f"{added:%Y-%m-%d} (age {age} days)" + except StopIteration: + added_text = "" + + toml.write(f"# added on {added_text}, last modified on {modified_text}\n") keywords = ", ".join(f'"{x}"' for x in sort_keywords(arches)) toml.write(f'"{pkg.versioned_atom}" = [{keywords}]\n') toml.write("\n\n") -- cgit v1.2.3-65-gdbad