dotfiles/bin/git-changelog
Jacob Kiers 4ec08fcd76 Update all bin-scripts to include a description.
The description will always be on the third line.

Signed-off-by: Jacob Kiers <jacob@alphacomm.nl>
2014-04-30 11:06:35 +02:00

54 lines
861 B
Bash
Executable File

#!/bin/sh
# Creates a changelog from the git commits.
FILE=""
LIST=false
TAG="0.?.?"
while [ "$1" != "" ]; do
case $1 in
-l | --list )
LIST=true
;;
-t | --tag )
TAG=$2
shift
;;
* )
FILE=$1
;;
esac
shift
done
DATE=`date +'%Y-%m-%d'`
HEAD="\n### $DATE v$TAG\n\n"
if $LIST; then
version=$(git describe --tags --abbrev=0 $(git rev-list --tags --max-count=1))
if test -z "$version"; then
git log --pretty="format:* %s"
else
git log --pretty="format:* %s" $version..
fi
exit
fi
CHANGELOG=$FILE
if test "$CHANGELOG" = ""; then
CHANGELOG=`ls | egrep 'change|history' -i`
if test "$CHANGELOG" = ""; then
CHANGELOG='History.md';
fi
fi
tmp="/tmp/changelog"
printf "$HEAD" > $tmp
git-changelog --list >> $tmp
printf '\n' >> $tmp
if [ -f $CHANGELOG ]; then cat $CHANGELOG >> $tmp; fi
mv $tmp $CHANGELOG
$EDITOR $CHANGELOG