build: Update release-patch to handle bugfixes (#3446)

Bugfixes are done on branches that don't have an unreleased
section in the CHANGELOG which would cause the last line
to be deleted and the change put at the bottom of the
CHANGELOG. Now there is a test for the unreleased section
which if it exists does the old behavior. If not the new
message will be placed above the last version section.

Fixes: #2533

Signed-off-by: Joshua Shanks <jjshanks@gmail.com>

Co-authored-by: Stephan Renatus <stephan.renatus@gmail.com>
This commit is contained in:
Joshua Shanks
2021-05-12 01:08:04 -07:00
committed by GitHub
parent b118e2b611
commit c5eac6ad5b
+13 -1
View File
@@ -46,7 +46,8 @@ update_makefile() {
}
update_changelog() {
cat >_CHANGELOG.md <<EOF
if $(grep -q '## Unreleased' CHANGELOG.md) ; then
cat >_CHANGELOG.md <<EOF
$(awk '1;/## Unreleased/{exit}' CHANGELOG.md | sed '$d')
## $VERSION
@@ -54,7 +55,18 @@ $(awk '1;/## Unreleased/{exit}' CHANGELOG.md | sed '$d')
$(./build/changelog.py $LAST_VERSION HEAD)
$(sed '1,/## Unreleased/d' CHANGELOG.md)
EOF
else
cat >_CHANGELOG.md <<EOF
$(awk '{if ($1 == "##") {exit;} else {print $0}}' CHANGELOG.md)
## $VERSION
$(./build/changelog.py $LAST_VERSION HEAD)
$(awk '/^##/{f=1}f' CHANGELOG.md)
EOF
fi
mv _CHANGELOG.md CHANGELOG.md
}