Skip to content

Commit d1a7d3c

Browse files
committed
MNT: Update update_changes to handle squashed merges
1 parent bb3c312 commit d1a7d3c

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

tools/update_changes.sh

+19-5
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,30 @@ UPCOMING=$?
2323
HEADER="$1 ($(date '+%B %d, %Y'))"
2424
echo $HEADER >> newchanges
2525
echo $( printf "%${#HEADER}s" | tr " " "=" ) >> newchanges
26+
echo >> newchanges
2627

2728
if [[ "x$2" != "x" ]]; then
28-
echo "(\`Full changelog <https://github.com/nipy/nipype/milestone/$2?closed=1>\`__)" >> newchanges
29+
echo "(\`Full changelog <https://github.com/nipy/nipype/milestone/$2?closed=1>\`__)" >> newchanges
30+
echo >> newchanges
2931
fi
3032

3133
# Search for PRs since previous release
32-
git log --grep="Merge pull request" `git describe --tags --abbrev=0`..HEAD --pretty='format: * %b %s' | sed 's+Merge pull request \#\([^\d]*\)\ from\ .*+(https://github.com/nipy/nipype/pull/\1)+' >> newchanges
33-
echo "" >> newchanges
34-
echo "" >> newchanges
34+
MERGE_COMMITS=$( git log --grep="Merge pull request\|(#.*)$" `git describe --tags --abbrev=0`..HEAD --pretty='format:%h' )
35+
for COMMIT in ${MERGE_COMMITS//\n}; do
36+
SUB=$( git log -n 1 --pretty="format:%s" $COMMIT )
37+
if ( echo $SUB | grep "^Merge pull request" ); then
38+
# Merge commit
39+
PR=$( echo $SUB | sed -e "s/Merge pull request \#\([0-9]*\).*/\1/" )
40+
TITLE=$( git log -n 1 --pretty="format:%b" $COMMIT )
41+
else
42+
# Squashed merge
43+
PR=$( echo $SUB | sed -e "s/.*(\#\([0-9]*\))$/\1/" )
44+
TITLE=$( echo $SUB | sed -e "s/\(.*\)(\#[0-9]*)$/\1/" )
45+
fi
46+
echo " * $TITLE (https://github.com/nipy/nipype/pull/$PR)" >> newchanges
47+
done
48+
echo >> newchanges
49+
echo >> newchanges
3550

3651
# Append old CHANGES
3752
if [[ "$UPCOMING" == "0" ]]; then
@@ -43,4 +58,3 @@ fi
4358

4459
# Replace old CHANGES with new file
4560
mv newchanges $CHANGES
46-

0 commit comments

Comments
 (0)