mirror of
https://gitlab.com/fedora/sigs/sway/sway-config-fedora.git
synced 2024-10-18 06:34:03 +02:00
43c6da5b5c
As documented in https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/#_snapshots
38 lines
835 B
Bash
38 lines
835 B
Bash
#!/bin/bash
|
|
# vim ft:sh
|
|
|
|
function git_tag {
|
|
git describe --tags --abbrev=0 2>/dev/null | head -n 1
|
|
}
|
|
|
|
function git_commit_count {
|
|
local tag=$1
|
|
if [ -n "$tag" ]; then
|
|
git rev-list "$tag"..HEAD --count 2>/dev/null || printf 0
|
|
else
|
|
git rev-list HEAD --count 2>/dev/null || printf 0
|
|
fi
|
|
}
|
|
|
|
function git_version {
|
|
tag="$(git_tag)"
|
|
tag_version="$(echo "$tag" | sed -E -n "s/^v?([^-]+)/\1/p")"
|
|
if [ -z "$tag_version" ]; then
|
|
tag_version=0
|
|
fi
|
|
commit_count="$(git_commit_count "$tag")"
|
|
if [ "$commit_count" -eq 0 ]; then
|
|
output "$tag_version"
|
|
else
|
|
shortcommit="$(git rev-parse --short HEAD)"
|
|
output "$tag_version^${commit_count}.git${shortcommit}"
|
|
fi
|
|
}
|
|
|
|
function git_release {
|
|
output "1"
|
|
}
|
|
|
|
function git_dir_release {
|
|
git_release "$@"
|
|
}
|