Fixes changelog et version computation
This commit is contained in:
parent
9a46f34f73
commit
253c77489b
|
@ -1,5 +1,4 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
cd src
|
cd src
|
||||||
if [ -f debian/changelog ] || [ ! -d .git ]; then
|
if [ -f debian/changelog ] || [ ! -d .git ]; then
|
||||||
tamarin_info "Not a Git repository or Debian changelog already exists !"
|
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
|
# Set starting commit
|
||||||
ceiling_commit=$(git describe --match "build/*" --abbrev=0 2>/dev/null)
|
ceiling_commit=$(git describe --match "build/*" --abbrev=0 2>/dev/null)
|
||||||
if [ -n "ceiling_commit" ]
|
if [ -z "ceiling_commit" ]
|
||||||
then
|
then
|
||||||
ceiling_commit="HEAD"
|
ceiling_commit="HEAD"
|
||||||
fi
|
fi
|
||||||
|
@ -55,7 +54,7 @@ function get_short_hash {
|
||||||
function get_previous_pkg_tag {
|
function get_previous_pkg_tag {
|
||||||
# Return previous pkg/* tag or current tag if no previous pkg/* exists.
|
# Return previous pkg/* tag or current tag if no previous pkg/* exists.
|
||||||
commit="$1"
|
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 {
|
function parse_tag {
|
||||||
|
@ -103,6 +102,18 @@ function get_package_version_from_tag {
|
||||||
echo "$package"
|
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 {
|
function get_previous_release_tag {
|
||||||
# Return previous pkg/* tag or current tag if no previous pkg/* exists.
|
# Return previous pkg/* tag or current tag if no previous pkg/* exists.
|
||||||
commit="$1"
|
commit="$1"
|
||||||
|
@ -113,7 +124,7 @@ function on_pkg_tag {
|
||||||
# Return 1 if current commit is tagged with pkg/* tag.
|
# Return 1 if current commit is tagged with pkg/* tag.
|
||||||
commit="$1"
|
commit="$1"
|
||||||
nearest_old_pkg_tag="$(get_previous_pkg_tag $commit)"
|
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
|
then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
|
@ -159,13 +170,13 @@ function date_from_commit {
|
||||||
function packager_from_commit {
|
function packager_from_commit {
|
||||||
# Return Name <mail> id format, suitable for changelog entry signature
|
# Return Name <mail> id format, suitable for changelog entry signature
|
||||||
commit="$1"
|
commit="$1"
|
||||||
if [ "${commit}" = "HEAD" ]
|
if on_pkg_tag "${commit}"
|
||||||
then
|
then
|
||||||
maintainer="$(git log -n1 --format='%cn <%ce>')"
|
|
||||||
else
|
|
||||||
maintainer_commit="$(get_previous_pkg_tag $commit)"
|
maintainer_commit="$(get_previous_pkg_tag $commit)"
|
||||||
maintainer="$(git tag -l --format='%(creator)' ${maintainer_commit})"
|
maintainer="$(git tag -l --format='%(creator)' ${maintainer_commit})"
|
||||||
maintainer="${maintainer%>*}>"
|
maintainer="${maintainer%>*}>"
|
||||||
|
else
|
||||||
|
maintainer="$(git log -n1 --format='%cn <%ce>')"
|
||||||
fi
|
fi
|
||||||
maintainer=$(tamarin_db get maintainer "${maintainer}")
|
maintainer=$(tamarin_db get maintainer "${maintainer}")
|
||||||
echo "$maintainer"
|
echo "$maintainer"
|
||||||
|
@ -190,6 +201,7 @@ function next_version {
|
||||||
fi
|
fi
|
||||||
elif [ -n "$previous_release" ]
|
elif [ -n "$previous_release" ]
|
||||||
then
|
then
|
||||||
|
distance_from_release=$(get_distance_from_tag "$previous_release" "$commit")
|
||||||
distance=$distance_from_release
|
distance=$distance_from_release
|
||||||
version="$(get_upstream_version_from_tag $previous_release)-1"
|
version="$(get_upstream_version_from_tag $previous_release)-1"
|
||||||
elif [ -n "$previous_pkg" ]
|
elif [ -n "$previous_pkg" ]
|
||||||
|
@ -219,9 +231,11 @@ function gen_changelog_entry {
|
||||||
if on_pkg_tag $ceiling_commit
|
if on_pkg_tag $ceiling_commit
|
||||||
then
|
then
|
||||||
version="$(get_upstream_version_from_tag $ceiling_commit)-$(get_package_version_from_tag $ceiling_commit)"
|
version="$(get_upstream_version_from_tag $ceiling_commit)-$(get_package_version_from_tag $ceiling_commit)"
|
||||||
|
distribution="$(get_distribution_from_tag $ceiling_commit)"
|
||||||
else
|
else
|
||||||
tamarin_info "current commit $ceiling_commit"
|
tamarin_info "current commit $ceiling_commit"
|
||||||
version=$(next_version $ceiling_commit)
|
version=$(next_version $ceiling_commit)
|
||||||
|
distribution="UNRELEASED"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#current_release="$(git describe --abbrev=0 --always --match='release/*' $ceiling_commit)"
|
#current_release="$(git describe --abbrev=0 --always --match='release/*' $ceiling_commit)"
|
||||||
|
|
Loading…
Reference in New Issue