Skip to content

Commit f2ef5d5

Browse files
committed
fix: Update update_changes.sh
1 parent 0af776d commit f2ef5d5

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

.maint/update_changes.sh

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
#
33
# Collects the pull-requests since the latest release and
4-
# aranges them in the CHANGES.rst file.
4+
# aranges them in the CHANGES.rst.txt file.
55
#
66
# This is a script to be run before releasing a new version.
77
#
@@ -19,8 +19,29 @@ if [[ "$UPCOMING" == "0" ]]; then
1919
head -n3 CHANGES.rst >> newchanges
2020
fi
2121

22+
# Elaborate today's release header
23+
HEADER="$1 ($(date '+%B %d, %Y'))"
24+
echo $HEADER >> newchanges
25+
echo $( printf "%${#HEADER}s" | tr " " "=" ) >> newchanges
26+
echo "" >> newchanges
27+
2228
# Search for PRs since previous release
23-
git show --pretty='format: * %b %s' HEAD | sed 's/Merge pull request \#\([^\d]*\)\ from\ .*/(\#\1)/' >> newchanges
29+
MERGE_COMMITS=$( git log --grep="Merge pull request\|(#.*)$" `git describe --tags --abbrev=0`..HEAD --pretty='format:%h' )
30+
for COMMIT in ${MERGE_COMMITS//\n}; do
31+
SUB=$( git log -n 1 --pretty="format:%s" $COMMIT )
32+
if ( echo $SUB | grep "^Merge pull request" ); then
33+
# Merge commit
34+
PR=$( echo $SUB | sed -e "s/Merge pull request \#\([0-9]*\).*/\1/" )
35+
TITLE=$( git log -n 1 --pretty="format:%b" $COMMIT )
36+
else
37+
# Squashed merge
38+
PR=$( echo $SUB | sed -e "s/.*(\#\([0-9]*\))$/\1/" )
39+
TITLE=$( echo $SUB | sed -e "s/\(.*\) (\#[0-9]*)$/\1/" )
40+
fi
41+
echo " * $TITLE (#$PR)" >> newchanges
42+
done
43+
echo >> newchanges
44+
echo >> newchanges
2445

2546
# Add back the Upcoming header if it was present
2647
if [[ "$UPCOMING" == "0" ]]; then
@@ -31,4 +52,3 @@ fi
3152

3253
# Replace old CHANGES.rst with new file
3354
mv newchanges CHANGES.rst
34-

0 commit comments

Comments
 (0)