Skip to content

Commit

Permalink
fix: now missing revision in dependency won't crash the app
Browse files Browse the repository at this point in the history
  • Loading branch information
katomaso committed Feb 27, 2024
1 parent 45d5664 commit 7e01430
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
9 changes: 0 additions & 9 deletions gira/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
13 changes: 10 additions & 3 deletions gira/gira.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
4 changes: 1 addition & 3 deletions gira/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7e01430

Please sign in to comment.