Skip to content

Commit d70af20

Browse files
committed
[ENH] Automate updates of CHANGES
Ref. #2313 (comment), item 5.
1 parent e0d829e commit d70af20

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tools/update_changes.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
#
3+
# Collects the pull-requests since the latest release and
4+
# aranges them in the CHANGES.txt file.
5+
#
6+
# This is a script to be run before releasing a new version.
7+
#
8+
# Usage /bin/bash update_changes.sh 1.0.1
9+
#
10+
11+
# Setting # $ help set
12+
set -e # Exit immediately if a command exits with a non-zero status.
13+
set -u # Treat unset variables as an error when substituting.
14+
set -x # Print command traces before executing command.
15+
16+
# Check whether the Upcoming release header is present
17+
head -1 CHANGES | grep -q Upcoming
18+
UPCOMING=$?
19+
if [[ "$UPCOMING" == "0" ]]; then
20+
head -n3 CHANGES >> newchanges
21+
fi
22+
23+
# Elaborate today's release header
24+
HEADER="$1 ($(date '+%B %d, %Y'))"
25+
echo $HEADER >> newchanges
26+
echo $( printf "%${#HEADER}s" | tr " " "=" ) >> newchanges
27+
echo "" >> newchanges
28+
29+
# Search for PRs since previous release
30+
git log --grep="Merge pull request" `git describe --tags --abbrev=0`..HEAD --pretty='format: * %b %s' | sed 's/Merge pull request \#\([^\d]*\)\ from\ .*/(\#\1)/' >> newchanges
31+
echo "" >> newchanges
32+
echo "" >> newchanges
33+
34+
# Add back the Upcoming header if it was present
35+
if [[ "$UPCOMING" == "0" ]]; then
36+
tail -n+4 CHANGES >> newchanges
37+
else
38+
cat CHANGES >> newchanges
39+
fi
40+
41+
# Replace old CHANGES with new file
42+
mv newchanges CHANGES
43+

0 commit comments

Comments
 (0)