Hilbish/rpkg.macros

26 lines
491 B
Plaintext
Raw Normal View History

function git_short_hash {
short_hash="$(cached git_short_hash)"
if [ -z "$short_hash" ]; then
short_hash="$(git rev-parse --short HEAD)"
fi
output "$short_hash"
}
function git_tag_version {
tag="$(cached git_tag_version)"
if [ -z "$tag" ]; then
tag="$(git describe --tags --abbrev=0)"
fi
# Remove the potential prefix of `v`
if [[ $tag =~ ^v[0-9].* ]]; then
tag="${tag:1}"
fi
2022-12-20 01:37:33 +00:00
tag="${tag/"-"/"."}"
output "$tag"
}