diff options
author | Ben Hilburn <bhilburn@gmail.com> | 2016-04-12 17:43:34 +0300 |
---|---|---|
committer | Ben Hilburn <bhilburn@gmail.com> | 2016-04-12 17:43:34 +0300 |
commit | 0f4e3e7588fff005a8ad275915f390817f804345 (patch) | |
tree | fadbd8f8549923b7a039ce96cc76ad379c500ec1 /functions | |
parent | 6fde7bf3fdce11ab38e50bbcc48e96cb22166d42 (diff) |
git-tagname: Now showing hash/branchname when sitting on a tag
Diffstat (limited to 'functions')
-rw-r--r-- | functions/vcs.zsh | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/functions/vcs.zsh b/functions/vcs.zsh index c2b8185a..3a5a6cb5 100644 --- a/functions/vcs.zsh +++ b/functions/vcs.zsh @@ -67,18 +67,17 @@ function +vi-git-tagname() { local tag tag=$(git describe --tags --exact-match HEAD 2>/dev/null) - # if [[ -z "$(git symbolic-ref HEAD 2>/dev/null)" || ! -z "${tag}" ]] ; then if [[ -n "${tag}" ]] ; then # There is a tag that points to our current commit. Need to determine if we # are also on a branch, or are in a DETACHED_HEAD state. - head=$(git describe --all) - # Make sure that detached head or checked out name differs from tag name - if [[ "${head}" != "${tag}" || - "$(git rev-parse --abbrev-ref HEAD)" != "${tag}" && - "$(git rev-parse --abbrev-ref HEAD)" != "HEAD" && - "$(git rev-list -n 1 HEAD)" == "$(git rev-list -n 1 ${tag})" ]]; then - # Append the tag segment to the branch one - [[ -n "${tag}" ]] && hook_com[branch]+=" $(print_icon 'VCS_TAG_ICON')${tag}" + if [[ -z $(git symbolic-ref HEAD 2>/dev/null) ]]; then + # DETACHED_HEAD state. Print the commit hash and tag name. + local revision + revision=$(git rev-list -n 1 --abbrev-commit --abbrev=8 HEAD) + hook_com[branch]="$(print_icon 'VCS_BRANCH_ICON')${revision} $(print_icon 'VCS_TAG_ICON')${tag}" + else + # We are on both a tag and a branch; print both. + hook_com[branch]+=" $(print_icon 'VCS_TAG_ICON')${tag}" fi fi } |