Skip to content

Commit

Permalink
Add backup alternative to getting remote repo if the primary way fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
hsorby committed May 16, 2024
1 parent 1165346 commit 8f703e0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/mapclient/core/provenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,25 @@ def _determine_git_repo(src_dir, check_parent=True):
return git_repo


def _backup_get_remote_repo(r):
config = r.get_config()
remote_name = b'origin'
remote_location = config.get((b'remote', remote_name), b"url")

return remote_name.decode(), remote_location.decode()


def remote_locations(src_dir):
git_repo = _determine_git_repo(src_dir, False)

if git_repo is None:
return "&&&&&&"

with dulwich.porcelain.open_repo_closing(git_repo) as r:
remote_repo_info = dulwich.porcelain.get_remote_repo(r)
try:
remote_repo_info = dulwich.porcelain.get_remote_repo(r)
except IndexError:
remote_repo_info = _backup_get_remote_repo(r)

return remote_repo_info[1]

Expand Down

0 comments on commit 8f703e0

Please sign in to comment.