Skip to content

Commit

Permalink
Fix git issue in Versioned.get_remote_url
Browse files Browse the repository at this point in the history
  • Loading branch information
rgerkin committed Nov 5, 2017
1 parent 3d4bd01 commit b604ab3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion sciunit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
from quantities.quantity import Quantity
import cypy
import git
from git.exc import GitCommandError
from git.cmd import Git

PRINT_DEBUG_STATE = False # printd does nothing by default.

Expand Down Expand Up @@ -323,6 +325,13 @@ def get_remote_url(self, remote='origin'):
repo = self.get_repo()
remotes = {r.name:r for r in repo.remotes}
r = repo.remotes[0] if remote not in remotes else remotes[remote]
url = list(r.urls)[0]
try:
url = list(r.urls)[0]
except GitCommandError as ex:
if 'correct access rights' in str(ex):
# If ssh is not setup to access this repository
url = Git().execute(['git','config','--get','remote.%s.url' % r.name])
else:
raise ex
return url
remote_url = property(get_remote_url)

0 comments on commit b604ab3

Please sign in to comment.