5fa7824ea59ec12a976f348a83399e66699456ea

Author
Thanh Ha <zxiiro@gmail.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

git-prompt: fix error when multiple tags exist (#6998)

When a commit has multiple tags associated to it, the git-prompt will
throw the following error:

git_super_status:[:4: integer expression expected: v0.21.x\ntags/v0.21.5,
git_super_status:[:7: integer expression expected: origin/v0.21.x,
git_super_status:[:11: integer expression expected: origin/v0.21.x,
git_super_status:[:14: integer expression expected: v0.21.x
git_super_status:[:23: integer expression expected: v0.21.x

This is due to the prompt expecting the tag field to be a single word
with no spaces in between but if there are multiple tags the python
script returns a string with ', ' space separated list of tags.
This throws off the parser. The solution is to ensure that the python
script returns a space-less string ensuring the git-prompt parser to
properly parse the data.

Signed-off-by: Thanh Ha <zxiiro@linux.com>

Diff

 1diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py
 2index 14d87597358ef5978fe47478c385414879bf7701..a4d07cde65e15824f0f042af4404aaa6b7966f9e 100644
 3--- a/plugins/git-prompt/gitstatus.py
 4+++ b/plugins/git-prompt/gitstatus.py
 5@@ -22,7 +22,7 @@ def get_tagname_or_hash():
 6         tagname = 'tags/' + output[m.start()+len('tag: '): m.end()-1]
 7 
 8     if tagname:
 9-        return tagname
10+        return tagname.replace(' ', '')
11     elif hash_:
12         return hash_
13     return None