From c79e5b31f8a5e7b5863bb7fab43d80d364e3f682 Mon Sep 17 00:00:00 2001 From: Dan Feder Date: Mon, 6 Jun 2016 09:47:01 -0400 Subject: [PATCH 1/2] Add tag detection --- prompt.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/prompt.sh b/prompt.sh index 6a737b8..f81d76c 100644 --- a/prompt.sh +++ b/prompt.sh @@ -2,8 +2,13 @@ find_git_branch() { # Based on: http://stackoverflow.com/a/13003854/170413 local branch if branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null); then + # check to see if on a tag if [[ "$branch" == "HEAD" ]]; then - branch='detached*' + if tag=$(git describe --exact-match >&1 2> /dev/null); then + branch="tags/$tag" + else + branch='detached*' + fi fi git_branch="($branch)" else From 15726014367d5271128c825684bfd6cbabdaf8ef Mon Sep 17 00:00:00 2001 From: Dan Feder Date: Wed, 14 Aug 2019 14:34:07 -0400 Subject: [PATCH 2/2] Fix tag command to recognize non-annotated tags --- prompt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prompt.sh b/prompt.sh index f81d76c..98887e5 100644 --- a/prompt.sh +++ b/prompt.sh @@ -4,7 +4,7 @@ find_git_branch() { if branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null); then # check to see if on a tag if [[ "$branch" == "HEAD" ]]; then - if tag=$(git describe --exact-match >&1 2> /dev/null); then + if tag=$(git describe --exact-match --tags >&1 2> /dev/null); then branch="tags/$tag" else branch='detached*'