Skip to content

Commit d8e5717

Browse files
committed
fix(git): Status with branches that contain periods
1 parent 517f9e0 commit d8e5717

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

libvcs/git.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def extract_status(value):
6464
branch.head
6565
[\W]+
6666
(?P<branch_head>
67-
[\w-]*
67+
[/.\w-]*
6868
)
6969
7070
)?
@@ -74,7 +74,7 @@ def extract_status(value):
7474
branch.upstream
7575
[\W]+
7676
(?P<branch_upstream>
77-
[/\w-]*
77+
[/.\w-]*
7878
)
7979
)?
8080
(
@@ -301,17 +301,20 @@ def update_repo(self):
301301
# Pull changes from the remote branch
302302
try:
303303
process = self.run(['rebase', git_remote_name + '/' + git_tag])
304-
except exc.CommandError:
305-
# Rebase failed: Restore previous state.
306-
self.run(['rebase', '--abort'])
307-
if need_stash:
308-
self.run(['stash', 'pop', '--index', '--quiet'])
309-
310-
self.error(
311-
"\nFailed to rebase in: '%s'.\n"
312-
"You will have to resolve the conflicts manually" % self.path
313-
)
314-
return
304+
except exc.CommandError as e:
305+
if 'invalid_upstream' in str(e):
306+
self.error(e)
307+
else:
308+
# Rebase failed: Restore previous state.
309+
self.run(['rebase', '--abort'])
310+
if need_stash:
311+
self.run(['stash', 'pop', '--index', '--quiet'])
312+
313+
self.error(
314+
"\nFailed to rebase in: '%s'.\n"
315+
"You will have to resolve the conflicts manually" % self.path
316+
)
317+
return
315318

316319
if need_stash:
317320
try:

tests/test_git.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,22 @@ def test_extract_status():
287287
'# branch.upstream moo/origin/myslash/remote',
288288
{"branch_upstream": 'moo/origin/myslash/remote'},
289289
],
290+
[
291+
"""
292+
# branch.oid c3c5323abc5dca78d9bdeba6c163c2a37b452e69
293+
# branch.head libvcs-0.4.0
294+
# branch.upstream origin/libvcs-0.4.0
295+
# branch.ab +0 -0
296+
""",
297+
{
298+
"branch_oid": 'c3c5323abc5dca78d9bdeba6c163c2a37b452e69',
299+
"branch_head": 'libvcs-0.4.0',
300+
"branch_upstream": 'origin/libvcs-0.4.0',
301+
"branch_ab": '+0 -0',
302+
"branch_ahead": '0',
303+
"branch_behind": '0',
304+
},
305+
],
290306
],
291307
)
292308
def test_extract_status_b(fixture, expected_result):

0 commit comments

Comments
 (0)