Tamarin/hooks/prebuild/debian/create-changelog

70 lines
1.8 KiB
Plaintext
Raw Normal View History

2015-08-04 23:58:43 +02:00
#!/usr/bin/env bash
2017-02-09 21:53:24 +01:00
cd src
2015-08-04 23:58:43 +02:00
if [ -f debian/changelog ] || [ ! -d .git ]; then
2017-02-09 21:53:24 +01:00
tamarin_info "Not a Git repository or Debian changelog already exists !"
2015-08-04 23:58:43 +02:00
exit
fi
# Get commits log as changelog
2017-02-09 21:53:24 +01:00
BUILD_TAG=$(tamarin_db get build_tag "last")
2015-08-20 17:35:43 +02:00
2017-02-09 21:53:24 +01:00
tamarin_debug "BUILD TAG IS ${BUILD_TAG}"
2015-08-20 17:35:43 +02:00
if [[ ${BUILD_TAG} == "last" ]]
then
tags=$(git describe --match "release/*" --abbrev=0)
2015-08-20 17:35:43 +02:00
else
tagbranch="build-tag-${BUILD_TAG}"
2015-09-23 17:42:08 +02:00
git checkout -b ${tagbranch}
2017-02-09 21:53:24 +01:00
tamarin_db set "tag_branch" "${tag_branch}"
2015-09-23 21:21:30 +02:00
local tags="${BUILD_TAG}"
2015-08-20 17:35:43 +02:00
fi
2015-08-04 23:58:43 +02:00
if [[ -z ${tags} ]]
then
2017-02-09 21:53:24 +01:00
tamarin_warn "No release tag found, you repo must have a tag like 'release/X.X'"
exit
fi
touch debian/changelog
for tag in ${tags}
do
logs=$(git log --pretty=format:"%an - %h : %s" ${tag} | sed 's/"/\\"/g')
# Set the top commiter as the maintainer of the project if not defined
top_contributor=$(git log --pretty=short | git shortlog -s -n -e | sed 's/^\s*[0-9]*\s*//g' | head -n 1)
2017-02-09 21:53:24 +01:00
maintainer=$(tamarin_db get maintainer "${top_contributor}")
2015-08-04 23:58:43 +02:00
2017-02-09 21:53:24 +01:00
project_name=$(tamarin_db get project_name)
version=${tag#*/} #$(get_opt version 0.0.0)
version=${version/_/-} #$(get_opt version 0.0.0)
2015-09-23 21:21:30 +02:00
2017-02-09 21:53:24 +01:00
distribution=$(tamarin_db get distribution UNRELEASED)
urgency=$(tamarin_db get urgency low)
2015-08-04 23:58:43 +02:00
2015-11-18 10:45:20 +01:00
package_version=${version}
2015-09-23 21:21:30 +02:00
2017-02-09 21:53:24 +01:00
# Define project_version if not defined
if [ -z "$(tamarin_db get project_version)" ]; then
2015-09-23 21:59:29 +02:00
# Share computed project version
2017-02-09 21:53:24 +01:00
tamarin_db set project_version "${version}"
2015-09-23 21:21:30 +02:00
fi
2015-11-18 10:45:20 +01:00
echo "${project_name} (${version}) ${distribution}; urgency=${urgency}" >> debian/changelog
2015-08-04 23:58:43 +02:00
echo >> debian/changelog
2015-08-04 23:58:43 +02:00
while read -r entry; do
2015-08-04 23:58:43 +02:00
echo " * ${entry}" >> debian/changelog
done <<< "$(echo -e "${logs}" | sed 's/^"//')"
2015-08-04 23:58:43 +02:00
echo >> debian/changelog
2015-08-04 23:58:43 +02:00
echo " -- ${maintainer} $(date -R)" >> debian/changelog
echo >> debian/changelog
done