Merge pull request #102 from Phally/tag-in-command-line

Entering the tag name in the command line with git-changelog
This commit is contained in:
TJ Holowaychuk 2013-05-15 10:01:22 -07:00
commit 111f04bb57
3 changed files with 49 additions and 29 deletions

View file

@ -458,9 +458,9 @@ since the previous tag. (If there are no tags, populates commits since the proj
Opens the changelog in `$EDITOR` when set.
```bash
$ git changelog && cat History.md
$ git changelog --tag 1.5.2 && cat History.md
n.n.n / 2010-08-05
1.5.2 / 2010-08-05
==================
* Docs for git-ignore. Closes #3

View file

@ -1,29 +1,49 @@
#!/bin/sh
DATE=`date +'%Y-%m-%d'`
HEAD="\nn.n.n / $DATE \n==================\n\n"
FILE=""
LIST=false
TAG="n.n.n"
case "$1" in
-l|--list)
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
;;
*)
CHANGELOG=$1
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
test -n "$EDITOR" && $EDITOR $CHANGELOG
;;
esac
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$TAG / $DATE \n==================\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
test -n "$EDITOR" && $EDITOR $CHANGELOG

View file

@ -5,7 +5,7 @@ _git_bug(){
}
_git_changelog(){
__gitcomp "--list"
__gitcomp "-l -t --list --tag"
}
_git_contrib(){