Skip to content

Instantly share code, notes, and snippets.

@alexec
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alexec/6d4956afd9f2d0735e1a to your computer and use it in GitHub Desktop.
Save alexec/6d4956afd9f2d0735e1a to your computer and use it in GitHub Desktop.
Create a CHANGELOG.md from Git history on Github
#! /bin/sh
# Creates a markdown formatted change log based the git history
set -eu
read -p "Enter your username:" USER > /dev/stderr
read -s -p "Please enter $USER's password:" PASS > /dev/stderr
OWNER=$(git remote show origin|grep "Fetch URL"|sed 's/.*https:...*\/\(.*\)\/\(.*\).git/\1/')
REPO=$(git remote show origin|grep "Fetch URL"|sed 's/.*https:...*\/\(.*\)\/\(.*\).git/\2/')
function pullDesc() {
PULL_NO=$1
F=/tmp/$OWNER-$REPO-pulls-$PULL_NO.json
if [ ! -e $F -o $(grep -c 'API rate limit exceeded' $F) -gt 0 ] ; then
U=https://$USER:$PASS@api.github.com/repos/$OWNER/$REPO/pulls/$PULL_NO
curl -fo $F $U --basic
fi
cat $F | grep title|sed 's/.*"\(.*\)",/\1/'
}
echo Change Log
echo ===
echo
git log --oneline --grep 'Merge pull request' --grep 'prepare release' | while read L ; do
if [ $(echo $L | grep -c 'Merge pull request') -eq 1 ] ; then
PULL_NO=$(echo $L | sed 's/.*#\([^ ]*\).*/\1/')
echo " * [#$PULL_NO](https://github.com/docker-java/docker-java/pull/$PULL_NO) $(pullDesc $PULL_NO)"
elif [ $(echo $L | grep -c 'prepare release') -eq 1 ] ; then
echo
echo $(echo $L | sed 's/.*prepare release//')
echo ---
echo
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment