mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-26 22:10:06 +00:00
Weird conditions handling
Become a programmer, they said. It'll be fun, they said.
This commit is contained in:
parent
ce16b087c6
commit
14e213bd68
1 changed files with 12 additions and 8 deletions
|
@ -62,16 +62,20 @@ function +vi-git-remotebranch() {
|
||||||
|
|
||||||
function +vi-git-tagname() {
|
function +vi-git-tagname() {
|
||||||
# Only show the tag name if we are not in DETACHED_HEAD state,
|
# Only show the tag name if we are not in DETACHED_HEAD state,
|
||||||
# since in that case it would already be displayed in the branch segment
|
# or if the current branch's HEAD is the same commit as a tag but
|
||||||
if [[ -z "$(git symbolic-ref HEAD 2>/dev/null)" ]] ; then
|
# doesn't have the same name
|
||||||
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
|
||||||
head=$(git describe --all)
|
head=$(git describe --all)
|
||||||
# Make sure that detached head and tag differ in name
|
# Make sure that detached head or checked out name differs from tag name
|
||||||
if [[ "${head}" != "${tag}" ]]; then
|
if [[ "${head}" != "${tag}" ||
|
||||||
# Append the tag segment to the branch one
|
"$(git rev-parse --abbrev-ref HEAD)" != "${tag}" &&
|
||||||
[[ -n "${tag}" ]] && hook_com[branch]+=" $(print_icon 'VCS_TAG_ICON')${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}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue