Skip to content

Commit

Permalink
MAINT: Update maintenance scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
mgxd committed Dec 13, 2022
1 parent fbe1023 commit 38951d9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
27 changes: 20 additions & 7 deletions .maint/update_changes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ set -u # Treat unset variables as an error when substituting.
set -x # Print command traces before executing command.

# Check whether the Upcoming release header is present
head -1 CHANGES.rst | grep -q Upcoming
head -1 CHANGES.md | grep -q Upcoming
UPCOMING=$?
if [[ "$UPCOMING" == "0" ]]; then
head -n3 CHANGES.rst >> newchanges
head -n3 CHANGES.md >> newchanges
fi

# Elaborate today's release header
Expand All @@ -26,15 +26,28 @@ echo $( printf "%${#HEADER}s" | tr " " "=" ) >> newchanges
echo "" >> newchanges

# Search for PRs since previous release
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
echo "" >> newchanges
echo "" >> newchanges
MERGE_COMMITS=$( git log --grep="Merge pull request\|(#.*)$" `git describe --tags --abbrev=0`..HEAD --pretty='format:%h' )
for COMMIT in ${MERGE_COMMITS//\n}; do
SUB=$( git log -n 1 --pretty="format:%s" $COMMIT )
if ( echo $SUB | grep "^Merge pull request" ); then
# Merge commit
PR=$( echo $SUB | sed -e "s/Merge pull request \#\([0-9]*\).*/\1/" )
TITLE=$( git log -n 1 --pretty="format:%b" $COMMIT )
else
# Squashed merge
PR=$( echo $SUB | sed -e "s/.*(\#\([0-9]*\))$/\1/" )
TITLE=$( echo $SUB | sed -e "s/\(.*\) (\#[0-9]*)$/\1/" )
fi
echo " * $TITLE (#$PR)" >> newchanges
done
echo >> newchanges
echo >> newchanges

# Add back the Upcoming header if it was present
if [[ "$UPCOMING" == "0" ]]; then
tail -n+4 CHANGES.rst >> newchanges
tail -n+4 CHANGES.md >> newchanges
else
cat CHANGES.rst >> newchanges
cat CHANGES.md >> newchanges
fi

# Replace old CHANGES.md with new file
Expand Down
2 changes: 1 addition & 1 deletion .maint/update_zenodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,4 @@ def get_git_lines(fname='line-contributors.txt'):
if isinstance(creator['affiliation'], list):
creator['affiliation'] = creator['affiliation'][0]

zenodo_file.write_text('%s\n' % json.dumps(zenodo, indent=2))
zenodo_file.write_text('%s\n' % json.dumps(zenodo, indent=2, ensure_ascii=False))

0 comments on commit 38951d9

Please sign in to comment.