Skip to content

Instantly share code, notes, and snippets.

@mablae
Last active December 29, 2015 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mablae/7677445 to your computer and use it in GitHub Desktop.
Save mablae/7677445 to your computer and use it in GitHub Desktop.
Creates a GIT Changelog based on Tags
#!/bin/bash
tags=()
for tag in $(git for-each-ref --sort='-refname:short' --format='%(refname:short)' refs/tags) ; do
tags+=($tag)
done
lastTag=0
totalTags=${#tags[*]}
mylog="changelog.txt"
echo "" > "$mylog"
for (( i=0; i<= $(($totalTags - 1)); i++ )) ; do
printOut=${tags["$i"]}
next=${tags["$i"+1]}
currentTag="$i"
echo "v. $printOut" >> $mylog
if (( $i+1==$totalTags )) ; then
git log --date=short --oneline --format=' - %s' "$printOut" >> "$mylog"
else
git log --date=short --oneline --format=' - %s' "$next".."$printOut" >> "$mylog"
fi
lastTag="$currentTag"
echo "" >> "$mylog"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment