Skip to content

Commit ef69f0c

Browse files
committed
get_current_remote_name: Use extract_status
1 parent 17d6a0c commit ef69f0c

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

libvcs/git.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -521,14 +521,8 @@ def get_current_remote_name(self):
521521
522522
:rtype: str, None if no remote set
523523
"""
524-
current_status = self.run(['status', '-sb'])
525-
# git status -sb
526-
# ## v1.0-ourbranch...remotename/v1.0-ourbranch
527-
match = re.match(
528-
r'^## (?P<branch>.*)\.{3}(?P<remote_slash_branch>.*)', current_status,
529-
)
530-
if match is None: # No upstream set
531-
return None
532-
return match.group('remote_slash_branch').replace(
533-
'/' + match.group('branch'), ''
534-
)
524+
match = extract_status(self.run(['status', '-sb', '--porcelain=2']))
525+
526+
if match['branch_upstream'] is None: # no upstream set
527+
return match['branch_head']
528+
return match['branch_upstream'].replace('/' + match['branch_head'], '')

0 commit comments

Comments
 (0)