From 3cf7fbba8db5882596d9059b73293cb45761b12b Mon Sep 17 00:00:00 2001 From: Jack Sullivan Date: Sat, 27 Jul 2013 18:31:39 -0400 Subject: [PATCH] Added support for tags If you are on a commit hash that has a tag, it will display the tag's name instead of the commit hash on the prompt. --- gitstatus.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gitstatus.py b/gitstatus.py index 63f4e44..a61187c 100755 --- a/gitstatus.py +++ b/gitstatus.py @@ -40,8 +40,13 @@ else: remote = '' +tag, tag_error = Popen(['git', 'describe', '--exact-match'], stdout=PIPE, stderr=PIPE).communicate() + if not branch: # not on any branch - branch = symbols['prehash']+ Popen(['git','rev-parse','--short','HEAD'], stdout=PIPE).communicate()[0][:-1] + if tag: # if we are on a tag, print the tag's name + branch = tag + else: + branch = symbols['prehash']+ Popen(['git','rev-parse','--short','HEAD'], stdout=PIPE).communicate()[0][:-1] else: remote_name = Popen(['git','config','branch.%s.remote' % branch], stdout=PIPE).communicate()[0].strip() if remote_name: