Refactor changelog based on git history

This commit is contained in:
2020-08-25 11:25:34 +02:00
parent 0d5470e1a7
commit 878b8c48ce
2 changed files with 203 additions and 77 deletions

View File

@ -3,7 +3,7 @@
cd src
if [ ! -f debian/changelog ]; then
tamarin_info "No changelog. Skipping..."
tamarin_info "No changelog. Skipping adding suffix to package version"
exit
fi
@ -12,21 +12,28 @@ if [ $(tamarin_db get no_version_suffix 'no') == 'yes' ]; then
exit
fi
tamarin_info "Suffixing package version"
if [ -d .git ]; then
tamarin_info "It seems to be a Git repository. Generating version suffix based on Git history..."
commit_tag=$(git describe --match "pkg/*")
pkg_tag=$(git describe --match "pkg/*" --abbrev=0)
commit_count=$(git rev-list --count ${pkg_tag}..HEAD)
current_commit=$(git log -n1 --pretty=format:%h)
tamarin_info $pkg_tag
tamarin_info $commit_count
tamarin_info $current_commit
version_suffix=~${commit_count}.${current_commit}
release_tag=$(git describe --match "release/*" --abbrev=0 2>/dev/null)
if [ -z "${release_tag}" ]
then
dev_commit_count=$(git rev-list --count --no-merges develop)
else
dev_commit_count=$(git rev-list --count ${release_tag}..master)
fi
if [ ${dev_commit_count} -gt 0 ]
then
build_level=$(tamarin_db get build_level 'dev')
version_suffix="~$build_level+${dev_commit_count}-$(git log -n1 --format=%h)"
else
version_suffix=''
fi
else
tamarin_info "Not a Git project. Fallback to timestamp for suffix generation..."
version_suffix=tamarin$(date +%Y%m%d%H%M)
fi
tamarin_info $version_suffix
tamarin_info "Suffixing package version with $version_suffix"
sed -i "0,/(\(.*\))/s/(\(.*\))/(\1${version_suffix})/" debian/changelog
cp debian/changelog /dist/changelog