git-changelog script.

This commit is contained in:
Artem Sapegin 2013-10-29 13:10:12 +04:00
parent 9d4659ca3f
commit 5d3f3f54e4
1 changed files with 52 additions and 0 deletions

52
bin/git-changelog Executable file
View File

@ -0,0 +1,52 @@
#!/bin/sh
# Based on git-extras
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
subl $CHANGELOG