Permalink
Browse files

Fix formatting of the release CHANGELOG file

- Add backquotes around the changelog
- Add empty line at the end of the changelog
- Enforce the use of the master changelog prior to release

Fixes #2281.

--
Change-Id: I449f5209a6b05e65411a64ce82ea1d89d60ee4d3
Reviewed-on: https://cr.bazel.build/8044
PiperOrigin-RevId: 144080940
MOS_MIGRATED_REVID=144080940
  • Loading branch information...
1 parent 4b5cfe4 commit 9f915545df4ca6dae044b9e02186b3616ddf5418 @damienmg damienmg committed with mhlopko Jan 10, 2017
Showing with 52 additions and 11 deletions.
  1. +16 −5 scripts/release/common.sh
  2. +9 −1 scripts/release/release.sh
  3. +27 −5 scripts/release/release_test.sh
@@ -196,19 +196,30 @@ function get_release_title() {
# Generate the release message to be added to the changelog
# from the release notes for release $1
+# Args:
+# $1: release name
+# $2: release ref (default HEAD)
+# $3: delimiter around the revision information (default none)
function generate_release_message() {
local release_name="$1"
local branch="${2:-HEAD}"
+ local delimiter="${3-}"
local baseline="$(get_release_baseline "${branch}")"
local cherrypicks="$(get_cherrypicks "${branch}" "${baseline}")"
-cat <<EOF
-$(get_release_title "$release_name")
+ get_release_title "$release_name"
+ echo
-$(create_revision_information $baseline $cherrypicks)
+ if [ -n "${delimiter}" ]; then
+ echo "${delimiter}"
+ fi
+ create_revision_information $baseline $cherrypicks
+ if [ -n "${delimiter}" ]; then
+ echo "${delimiter}"
+ fi
-$(get_release_notes "${branch}")
-EOF
+ echo
+ get_release_notes "${branch}"
}
# Returns the release notes for the CHANGELOG.md taken from either from
@@ -89,23 +89,31 @@ function release_note_editor() {
# Create the release commit by changing the CHANGELOG file
function create_release_commit() {
- local infos=$(generate_release_message "${1}")
+ local infos=$(generate_release_message "${1}" HEAD '```')
local changelog_path="$PWD/CHANGELOG.md"
+ local master=$(get_master_ref)
+
+ # Get the changelog from master to avoid missing release notes
+ # from release that were in-between
+ git checkout -q ${master} CHANGELOG.md || true
# CHANGELOG.md
local tmpfile="$(mktemp ${TMPDIR:-/tmp}/relnotes-XXXXXXXX)"
trap "rm -f ${tmpfile}" EXIT
echo -n "## ${infos}" >${tmpfile}
if [ -f "${changelog_path}" ]; then
echo >>${tmpfile}
+ echo >>${tmpfile}
cat "${changelog_path}" >>${tmpfile}
+ echo >>${tmpfile}
fi
cat "${tmpfile}" > ${changelog_path}
git add ${changelog_path}
rm -f "${tmpfile}"
trap - EXIT
# Commit
+ infos="$(echo "${infos}" | grep -Ev '^```$')"
git commit --no-verify -m "${infos}" --no-edit --author "${RELEASE_AUTHOR}"
}
@@ -199,6 +199,15 @@ function test_release_workflow() {
# Do the initial release
release v0
+ CHANGELOG='## Release v0 ('$(date +%Y-%m-%d)')
+
+```
+Baseline: 965c392
+```
+
+Initial release.'
+ assert_equals "${CHANGELOG}" "$(<CHANGELOG.md)"
+
# Second release.
# First we need to edit the logs
@@ -280,24 +289,37 @@ EOF
echo "${RELNOTES}" >${TEST_TMPDIR}/replacement.log
create v1 1170dc6 0540fde cef25c4
- header='Release v1rc2 ('$(date +%Y-%m-%d)')
-
-Baseline: 1170dc6
+ title='Release v1rc2 ('$(date +%Y-%m-%d)')'
+ revision_info='Baseline: 1170dc6
Cherry picks:
+ 0540fde: Extract version numbers that look like "..._1.2.3_..."
from BUILD_EMBED_LABEL into Info.plist.
+ cef25c4: RELNOTES: Attribute error messages related to Android
- resources are easier to understand now.
+ resources are easier to understand now.'
+ header="${title}
-'
+${revision_info}
+
+"
assert_equals "${header}${RELNOTES}" "$(cat ${TEST_log})"
assert_equals "${RELNOTES}" "$(get_release_notes release-v1)"
assert_equals 2 "$(get_release_candidate release-v1)"
# Push the release
push v1
release v1
+ title='Release v1 ('$(date +%Y-%m-%d)')'
+ CHANGELOG='## '"${title}"'
+
+```
+'"${revision_info}"'
+```
+
+'"${RELNOTES}"'
+
+'"${CHANGELOG}"
+ assert_equals "${CHANGELOG}" "$(<CHANGELOG.md)"
# Third release to test abandon
cat >${EDITOR} <<EOF

0 comments on commit 9f91554

Please sign in to comment.