mas/script/version

25 lines
577 B
Text
Raw Permalink Normal View History

#!/bin/zsh -Ndefgku
2019-01-13 00:18:35 -07:00
#
# script/version
# mas
#
# Displays the mas version.
2019-01-13 00:18:35 -07:00
#
. "${0:a:h}/_setup_script"
branch="${"$(git rev-parse --abbrev-ref HEAD)":/main}"
if [[ "${branch}" = HEAD ]]; then
if git merge-base --is-ancestor HEAD main; then
branch=
else
branch="${"${(@)"${(fnO)"$(git branch --format '%(ahead-behind:HEAD) %(refname:short)')"}"[1]}"##* }"
fi
fi
printf $'%s%s%s\n'\
"${branch:+"${branch}-"}"\
"${"$(git describe --tags 2>/dev/null)"#v}"\
"${"$(git diff-index HEAD --;git ls-files --exclude-standard --others)":+"${MAS_DIRTY_INDICATOR-+}"}"