willis: update regexp used to determine branches
The format of the output of 'git branch -vv' has changed with git
version 2.4.0. We need to handle the new format when searching
for branches.
BUG=none
BRANCH=none
TEST=manual
Run willis inside the chroot (git version 2.1.2) and outside
the chroot (2.5.0). Prior to this CL, *every* repo displayed its
master branch with the newer git.
With this CL, both inside and outside show the same information.
Change-Id: I42823f0b38d9cc27897d4ee2e3478bce3725dfa0
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295685
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
diff --git a/host/willis b/host/willis
index 3c4c398..f7ad1a5 100755
--- a/host/willis
+++ b/host/willis
@@ -176,15 +176,19 @@
#
# For versions older than git 1.8.x:
# `* (no branch) <sha_1> <description>'
- # Newer versions look like:
+ # For versions older than git 2.4.x:
# `* (detached from <sha_1>) <sha_1> <description>'
+ # Newer versions:
+ # `* (HEAD detached from <sha_1>) <sha_1> <description>'
+ # `* (HEAD detached at <sha_1>) <sha_1> <description>'
#
# The asterisk could be not there, the '(no branch)' substring could be
# enveloped in the color enable/disable escape sequences with spaces
# potentially before and after the escape sequence.
m = re.search(
- '\*? +[^ ]*\((no branch|detached from [^)]*)\) *(?:\x1b..)? *([^ ]+) ',
- branch)
+ '\*? +[^ ]*\((no branch|(?:HEAD )?detached (?:at|from) [^)]*)\)' +
+ ' *(?:\x1b..)? *([^ ]+) ',
+ branch)
if m:
branch_sha1 = m.groups(0)[1]
# Does detached HEAD match the tracking branch?