Skip to content

Commit eea2c6c

Browse files
committed
Fix corner case where empty repository doesn't have branches
In fact it has "master" branch as default, but it's not available before the first commit
1 parent 6d4e978 commit eea2c6c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mbed/mbed.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,10 @@ def getrev():
688688

689689
# Gets current branch or returns empty string if detached
690690
def getbranch():
691-
branch = pquery([git_cmd, 'rev-parse', '--symbolic-full-name', '--abbrev-ref', 'HEAD']).strip()
691+
try:
692+
branch = pquery([git_cmd, 'rev-parse', '--symbolic-full-name', '--abbrev-ref', 'HEAD']).strip()
693+
except ProcessException:
694+
branch = "master"
692695
return branch if branch != "HEAD" else ""
693696

694697
# Finds refs (local or remote branches). Will match rev if specified

0 commit comments

Comments
 (0)