rpkg: switch to the current snapshot versioning scheme

As documented in https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/#_snapshots
This commit is contained in:
Aleksei Bavshin 2022-12-19 08:10:41 -08:00
commit 43c6da5b5c
No known key found for this signature in database
GPG key ID: 4F071603387A382A

View file

@ -5,30 +5,32 @@ function git_tag {
git describe --tags --abbrev=0 2>/dev/null | head -n 1 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 { function git_version {
tag="$(git_tag)" tag="$(git_tag)"
tag_version="$(echo "$tag" | sed -E -n "s/^v?([^-]+)/\1/p")" tag_version="$(echo "$tag" | sed -E -n "s/^v?([^-]+)/\1/p")"
if [ -z "$tag_version" ]; then if [ -z "$tag_version" ]; then
tag_version=0 tag_version=0
fi fi
commit_count="$(git_commit_count "$tag")"
if [ "$commit_count" -eq 0 ]; then
output "$tag_version" output "$tag_version"
else
shortcommit="$(git rev-parse --short HEAD)"
output "$tag_version^${commit_count}.git${shortcommit}"
fi
} }
function git_release { function git_release {
latest_tag="$(git_tag)" output "1"
if [ -n "$latest_tag" ]; then
commit_count="$(git rev-list "$latest_tag"..HEAD --count 2>/dev/null)"
commit_count=$(( commit_count + 1 ))
else
commit_count="$(git rev-list HEAD --count 2>/dev/null || printf 0)"
fi
if [ -n "$latest_tag" ] && [ "$commit_count" -eq 1 ]; then
output "0.1"
else
snap_date="$(date +%+4Y%m%d)"
shortcommit="$(git rev-parse --short HEAD)"
output "0.$commit_count.${snap_date}git${shortcommit}"
fi
} }
function git_dir_release { function git_dir_release {