2018-11-08 03:02:12 +01:00
|
|
|
#! /bin/bash
|
2018-11-08 17:54:08 +01:00
|
|
|
# update tags
|
2018-11-08 03:02:12 +01:00
|
|
|
git fetch --tags
|
2018-11-08 17:54:08 +01:00
|
|
|
# get origin
|
2018-11-08 22:47:18 +01:00
|
|
|
URL='https://github.com/MetaMask/metamask-extension'
|
2018-11-08 17:56:22 +01:00
|
|
|
# get git logs from last tag until HEAD, pretty by 'subject::body' filtered by grep for PRs made with Github squash merge or Github regular merge
|
2018-11-08 17:54:08 +01:00
|
|
|
LOG=$(git log $(git describe --tags $(git rev-list --tags --max-count=1))..HEAD --pretty="%s::%b" --reverse --grep="Merge pull request #" --grep="(#");
|
2018-11-08 03:02:12 +01:00
|
|
|
while read -r line; do
|
2018-11-08 17:54:08 +01:00
|
|
|
# get git log subject
|
2018-11-08 18:51:07 +01:00
|
|
|
SUBJECT=$(echo $line | sed -E 's/(.*):{2}(.*)/\1/')
|
2018-11-08 17:54:08 +01:00
|
|
|
# get git log PR id, PR made with Github squash merge or Github regular merge
|
2018-11-08 17:23:48 +01:00
|
|
|
PR=$(echo $SUBJECT | sed 's/^.*(#\([^&]*\)).*/\1/' | sed 's/^.*#\([^&]*\) from.*/\1/')
|
2018-11-08 17:56:22 +01:00
|
|
|
# if PR made with Github squash merge, subject is the body
|
2018-11-08 19:25:52 +01:00
|
|
|
if [ -z "$(echo $line | sed -E 's/(.*):{2}(.*)/\2/')" ]; then
|
2018-11-08 17:54:08 +01:00
|
|
|
BODY=$(echo $SUBJECT | sed "s/(#$PR)//g"); else
|
|
|
|
BODY=$(echo $line | sed -E 's/(.*):{2}(.*)/\2/')
|
2018-11-08 03:02:12 +01:00
|
|
|
fi
|
2018-11-08 17:54:08 +01:00
|
|
|
# add entry to CHANGELOG
|
2018-11-08 23:04:38 +01:00
|
|
|
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
|
|
|
sed -i'' '/## Current Develop Branch/a\
|
|
|
|
- [#'"$PR"']('"$URL"'/pull/'"$PR"'): '"$BODY"''$'\n' CHANGELOG.md; else
|
|
|
|
sed -i '' '/## Current Develop Branch/a\
|
2018-11-08 22:32:56 +01:00
|
|
|
- [#'"$PR"']('"$URL"'/pull/'"$PR"'): '"$BODY"''$'\n' CHANGELOG.md;
|
2018-11-08 23:04:38 +01:00
|
|
|
fi
|
2018-11-08 03:02:12 +01:00
|
|
|
done <<< "$LOG"
|
2018-11-08 18:51:07 +01:00
|
|
|
echo 'CHANGELOG updated'
|