Skip to content

Commit d4ccd4d

Browse files
committed
GitRepo: get_current_remote_name: Handle case where no upstream set
1 parent 31cb438 commit d4ccd4d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

libvcs/git.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,14 +466,16 @@ def get_git_version(self):
466466
def get_current_remote_name(self):
467467
"""Retrieve name of the remote / upstream of currently checked out branch.
468468
469-
:rtype: str
469+
:rtype: str, None if no remote set
470470
"""
471471
current_status = self.run(['status', '-sb'])
472472
# git status -sb
473473
# ## v1.0-ourbranch...remotename/v1.0-ourbranch
474474
match = re.match(
475475
r'^## (?P<branch>.*)\.{3}(?P<remote_slash_branch>.*)', current_status,
476476
)
477+
if match is None: # No upstream set
478+
return None
477479
return match.group('remote_slash_branch').replace(
478480
'/' + match.group('branch'), ''
479481
)

0 commit comments

Comments
 (0)