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:
parent
642fdebf8c
commit
43c6da5b5c
1 changed files with 17 additions and 15 deletions
32
rpkg.macros
32
rpkg.macros
|
|
@ -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
|
||||||
output "$tag_version"
|
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 {
|
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 {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue