Fixes changelog et version computation

This commit is contained in:
Benjamin Bohard 2020-09-03 08:45:00 +02:00
parent 9a46f34f73
commit 253c77489b
1 changed files with 22 additions and 8 deletions

View File

@ -1,5 +1,4 @@
#!/usr/bin/env bash
cd src
if [ -f debian/changelog ] || [ ! -d .git ]; then
tamarin_info "Not a Git repository or Debian changelog already exists !"
@ -13,7 +12,7 @@ pkg_tags="$(git for-each-ref --format '%(refname)' refs/tags | tac)"
# Set starting commit
ceiling_commit=$(git describe --match "build/*" --abbrev=0 2>/dev/null)
if [ -n "ceiling_commit" ]
if [ -z "ceiling_commit" ]
then
ceiling_commit="HEAD"
fi
@ -55,7 +54,7 @@ function get_short_hash {
function get_previous_pkg_tag {
# Return previous pkg/* tag or current tag if no previous pkg/* exists.
commit="$1"
echo "$(git describe --abbrev=0 --always --match='pkg/*' $commit)"
echo "$(git describe --abbrev=0 --match='pkg/*' $commit 2>/dev/null)"
}
function parse_tag {
@ -103,6 +102,18 @@ function get_package_version_from_tag {
echo "$package"
}
function get_distribution_from_tag {
# tag pkg like pkg/<level>/<distrib>/<version>
# <distrib> may be composed
set -x
tag="$1"
distribution="${tag#pkg/*/}"
distribution="${distribution%/*}"
distribution="${distribution/\//-}"
echo $distribution
set +x
}
function get_previous_release_tag {
# Return previous pkg/* tag or current tag if no previous pkg/* exists.
commit="$1"
@ -113,7 +124,7 @@ function on_pkg_tag {
# Return 1 if current commit is tagged with pkg/* tag.
commit="$1"
nearest_old_pkg_tag="$(get_previous_pkg_tag $commit)"
if [ "$(get_hash ${commit})" = "$(get_hash ${nearest_old_pkg_tag})" ]
if [ -n "${nearest_old_pkg_tag}" ] && [ "$(get_hash ${commit})" = "$(get_hash ${nearest_old_pkg_tag})" ]
then
return 0
else
@ -159,13 +170,13 @@ function date_from_commit {
function packager_from_commit {
# Return Name <mail> id format, suitable for changelog entry signature
commit="$1"
if [ "${commit}" = "HEAD" ]
if on_pkg_tag "${commit}"
then
maintainer="$(git log -n1 --format='%cn <%ce>')"
else
maintainer_commit="$(get_previous_pkg_tag $commit)"
maintainer="$(git tag -l --format='%(creator)' ${maintainer_commit})"
maintainer="${maintainer%>*}>"
else
maintainer="$(git log -n1 --format='%cn <%ce>')"
fi
maintainer=$(tamarin_db get maintainer "${maintainer}")
echo "$maintainer"
@ -190,6 +201,7 @@ function next_version {
fi
elif [ -n "$previous_release" ]
then
distance_from_release=$(get_distance_from_tag "$previous_release" "$commit")
distance=$distance_from_release
version="$(get_upstream_version_from_tag $previous_release)-1"
elif [ -n "$previous_pkg" ]
@ -219,11 +231,13 @@ function gen_changelog_entry {
if on_pkg_tag $ceiling_commit
then
version="$(get_upstream_version_from_tag $ceiling_commit)-$(get_package_version_from_tag $ceiling_commit)"
distribution="$(get_distribution_from_tag $ceiling_commit)"
else
tamarin_info "current commit $ceiling_commit"
version=$(next_version $ceiling_commit)
distribution="UNRELEASED"
fi
#current_release="$(git describe --abbrev=0 --always --match='release/*' $ceiling_commit)"
tamarin_info "Création de lentrée de changelog entre ${ceiling_commit} et ${floor_commit}"