Skip to content

Instantly share code, notes, and snippets.

@Yago
Created March 13, 2017 13:04
Show Gist options
  • Save Yago/e055c82a1c75eae31f349e46481ca712 to your computer and use it in GitHub Desktop.
Save Yago/e055c82a1c75eae31f349e46481ca712 to your computer and use it in GitHub Desktop.
Dynamically update Changelog.md base on commits since last tag.
#!/bin/bash
LASTDATE=$(git show -s --format=%ad `git rev-list --tags --max-count=1`)
echo $1 > VERSION
touch CHANGELOG.tmp
echo `date +"*$1* (%Y-%m-%d)"` >> CHANGELOG.tmp
COMMITS=`git log --pretty=format:" - %s (%h);" --since="$LASTDATE"`
index=0
IFS=';'
for line in $COMMITS; do
read -r -p "$line [y/N] " response
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]
then
SAVED[$index]=$line
fi
((index++))
done
echo ${SAVED[@]} >> CHANGELOG.tmp
echo "" >> CHANGELOG.tmp
cat CHANGELOG.md >> CHANGELOG.tmp
mv CHANGELOG.tmp CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment