Skip to content

Commit

Permalink
Handle FileNotFoundError in git grep
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-z committed Jun 30, 2024
1 parent e2ba17c commit ae6fa51
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,14 @@ def get_raw_watcloud_uris(repo_path: Path):

# -h suppresses filename output
# --only-matching returns only the matched text
out = repo.git.execute(
["git", "grep", "--only-matching", "-h", "watcloud://[^\"' ]*"]
+ [r.name for r in repo.remote().refs]
)
try:
out = repo.git.execute(
["git", "grep", "--only-matching", "-h", "watcloud://[^\"' ]*"]
+ [r.name for r in repo.remote().refs]
)
except FileNotFoundError:
# when `git grep` can't find any matches, it throws a FileNotFoundError
pass
uris = set(u.strip() for u in out.splitlines() if u.strip())

return uris
Expand Down

0 comments on commit ae6fa51

Please sign in to comment.