Skip to content

Commit

Permalink
feat(rpkg): switch to the current snapshot versioning scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
alebastr committed Jun 15, 2023
1 parent 0fdb2c4 commit 73c8870
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions srpm/rpkg.macros
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,34 @@ 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
output "$tag_version"
}

function git_release {
latest_tag="$(git_tag)"
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"
commit_count="$(git_commit_count "$tag")"
if [ "$commit_count" -eq 0 ]; then
output "$tag_version"
else
snap_date="$(date +%+4Y%m%d)"
shortcommit="$(git rev-parse --short HEAD)"
output "0.$commit_count.${snap_date}git${shortcommit}"
output "$tag_version^${commit_count}.git${shortcommit}"
fi
}

function git_release {
output "1"
}

function git_dir_release {
git_release "$@"
}

0 comments on commit 73c8870

Please sign in to comment.