Skip to content

Commit a0ed3d9

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

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)