Skip to content

Commit

Permalink
Fix robustness of batch queries
Browse files Browse the repository at this point in the history
  • Loading branch information
douglaslassance committed Oct 10, 2024
1 parent 259b93e commit f8ae761
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions gitalong/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ async def get_files_last_commits(
"""
last_commits: List[git.Commit | dict] = []
for filename in filenames:
repository = Repository(filename)
last_commit = {}

repository = get_repository_safe(filename)
if not repository:
last_commits.append(last_commit)
continue

# We are checking the tracked commit first as they represented local changes.
# They are in nature always more recent. If we find a relevant commit here we
Expand All @@ -54,7 +59,6 @@ async def get_files_last_commits(
relevant_tracked_commits = []
filename = repository.get_relative_path(filename)
remote = repository.remote_url
last_commit = {}
track_uncommitted = repository.config.get("track_uncommitted", False)
for tracked_commit in tracked_commits:
if (
Expand Down
4 changes: 2 additions & 2 deletions gitalong/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def run_status(ctx, filename): # pylint: disable=missing-function-docstring
file_status = []
commits = asyncio.run(get_files_last_commits(filename))
for _filename, commit in zip(filename, commits):
repository = get_repository_safe(ctx.obj.get("REPOSITORY", "") or _filename)
repository = get_repository_safe(ctx.obj.get("REPOSITORY", _filename))
absolute_filename = (
repository.get_absolute_path(_filename) if repository else _filename
)
Expand All @@ -182,7 +182,7 @@ def claim(ctx, filename): # pylint: disable=missing-function-docstring
statuses = []
blocking_commits = asyncio.run(claim_files(filename))
for _filename, commit in zip(filename, blocking_commits):
repository = get_repository_safe(ctx.obj.get("REPOSITORY", "") or _filename)
repository = get_repository_safe(ctx.obj.get("REPOSITORY", _filename))
absolute_filename = (
repository.get_absolute_path(_filename) if repository else _filename
)
Expand Down

0 comments on commit f8ae761

Please sign in to comment.