git-tagname: Now showing hash/branchname when sitting on a tag
This commit is contained in:
parent
6fde7bf3fd
commit
0f4e3e7588
|
@ -67,18 +67,17 @@ function +vi-git-tagname() {
|
||||||
local tag
|
local tag
|
||||||
tag=$(git describe --tags --exact-match HEAD 2>/dev/null)
|
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
|
if [[ -n "${tag}" ]] ; then
|
||||||
# There is a tag that points to our current commit. Need to determine if we
|
# 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.
|
# are also on a branch, or are in a DETACHED_HEAD state.
|
||||||
head=$(git describe --all)
|
if [[ -z $(git symbolic-ref HEAD 2>/dev/null) ]]; then
|
||||||
# Make sure that detached head or checked out name differs from tag name
|
# DETACHED_HEAD state. Print the commit hash and tag name.
|
||||||
if [[ "${head}" != "${tag}" ||
|
local revision
|
||||||
"$(git rev-parse --abbrev-ref HEAD)" != "${tag}" &&
|
revision=$(git rev-list -n 1 --abbrev-commit --abbrev=8 HEAD)
|
||||||
"$(git rev-parse --abbrev-ref HEAD)" != "HEAD" &&
|
hook_com[branch]="$(print_icon 'VCS_BRANCH_ICON')${revision} $(print_icon 'VCS_TAG_ICON')${tag}"
|
||||||
"$(git rev-list -n 1 HEAD)" == "$(git rev-list -n 1 ${tag})" ]]; then
|
else
|
||||||
# Append the tag segment to the branch one
|
# We are on both a tag and a branch; print both.
|
||||||
[[ -n "${tag}" ]] && hook_com[branch]+=" $(print_icon 'VCS_TAG_ICON')${tag}"
|
hook_com[branch]+=" $(print_icon 'VCS_TAG_ICON')${tag}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -832,8 +832,8 @@ prompt_vcs() {
|
||||||
|
|
||||||
VCS_CHANGESET_PREFIX=''
|
VCS_CHANGESET_PREFIX=''
|
||||||
if [[ "$POWERLEVEL9K_SHOW_CHANGESET" == true ]]; then
|
if [[ "$POWERLEVEL9K_SHOW_CHANGESET" == true ]]; then
|
||||||
# Default: Just display the first 12 characters of our changeset-ID.
|
# Default: Just display the first 8 characters of our changeset-ID.
|
||||||
local VCS_CHANGESET_HASH_LENGTH=12
|
local VCS_CHANGESET_HASH_LENGTH=8
|
||||||
if [[ -n "$POWERLEVEL9K_CHANGESET_HASH_LENGTH" ]]; then
|
if [[ -n "$POWERLEVEL9K_CHANGESET_HASH_LENGTH" ]]; then
|
||||||
VCS_CHANGESET_HASH_LENGTH="$POWERLEVEL9K_CHANGESET_HASH_LENGTH"
|
VCS_CHANGESET_HASH_LENGTH="$POWERLEVEL9K_CHANGESET_HASH_LENGTH"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue