diff --git a/gira/cache.py b/gira/cache.py index 08ab765..bdd94cb 100644 --- a/gira/cache.py +++ b/gira/cache.py @@ -34,12 +34,3 @@ def cache(name: str, url: str) -> pygit2.Repository: ["git", "fetch", "origin"], cwd=str(repo_dir), check=True, capture_output=True ) return repo.Repo(repo_dir, ref="HEAD", bare=True) - - -def messages(name: str, url: str, a: str, b: str) -> list[str]: - """Return commit messages between two revisions a and b for cached git repository - - @deprecated use cache() and repo.messages() instead. - """ - repo = cache(name, url) - return repo.messages(a, b) diff --git a/gira/gira.py b/gira/gira.py index 4329b3f..1b3fd9a 100644 --- a/gira/gira.py +++ b/gira/gira.py @@ -53,9 +53,16 @@ def gira(config: config.Config, stream: TextIO, format: str, ref: Optional[str]) for upgrade in upgrades: if upgrade.messages is None: url = config.observe[upgrade.name] # this might return an object with more information - upgrade.messages = cache.cache(upgrade.name, url).messages( - upgrade.old_version, upgrade.new_version - ) + try: + upgrade.messages = cache.cache(upgrade.name, url).messages( + upgrade.old_version, upgrade.new_version + ) + except KeyError as e: + logger.error( + f"Repository {upgrade.name} does not contain {e.args[0]}." + " Might have been deleted locally or remotely. Skipping" + ) + continue logger.debug( f"Messages for {upgrade.name} between {upgrade.new_version} and" f" {upgrade.old_version}: {upgrade.messages}" diff --git a/gira/repo.py b/gira/repo.py index 5815f25..3da1936 100644 --- a/gira/repo.py +++ b/gira/repo.py @@ -122,9 +122,7 @@ def messages(self, a: str, b: Optional[str] = None): """ logger.debug(f"Getting messages between {a} and {b or self.ref} for {self.path.name}") past_commit = self.repo.revparse_single(a) - current_commit = ( - self.repo.revparse_single(self.ref) if b is None else self.repo.revparse_single(b) - ) + current_commit = self.repo.revparse_single(self.ref if b is None else b) if not isinstance(past_commit, pygit2.Commit): past_commit = past_commit.peel(pygit2.Commit)