From 1235e4a5ad9875590a07d02d02366d0907d300bf Mon Sep 17 00:00:00 2001 From: Phally Date: Sat, 5 May 2012 12:27:37 +0200 Subject: [PATCH 1/4] Added support for multiple arguments in git-changelog. --- bin/git-changelog | 63 +++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 24 deletions(-) diff --git a/bin/git-changelog b/bin/git-changelog index af602ce..d305cc2 100755 --- a/bin/git-changelog +++ b/bin/git-changelog @@ -1,29 +1,44 @@ #!/bin/sh +FILE="" +LIST=false + +while [ "$1" != "" ]; do + case $1 in + -l | --list ) + LIST=true + ;; + * ) + FILE=$1 + ;; + esac + shift +done + DATE=`date +'%Y-%m-%d'` HEAD="\nn.n.n / $DATE \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 +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 From 4f55198dca14224a38ff0029876b20296f95c5de Mon Sep 17 00:00:00 2001 From: Phally Date: Sat, 5 May 2012 12:35:42 +0200 Subject: [PATCH 2/4] Added support for a --tag argument to directly set the tag name in the header. --- bin/git-changelog | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/git-changelog b/bin/git-changelog index d305cc2..6bf1455 100755 --- a/bin/git-changelog +++ b/bin/git-changelog @@ -2,12 +2,17 @@ FILE="" LIST=false +TAG="n.n.n" while [ "$1" != "" ]; do case $1 in -l | --list ) LIST=true ;; + -t | --tag ) + TAG=$2 + shift + ;; * ) FILE=$1 ;; @@ -16,7 +21,7 @@ while [ "$1" != "" ]; do done DATE=`date +'%Y-%m-%d'` -HEAD="\nn.n.n / $DATE \n==================\n\n" +HEAD="\n$TAG / $DATE \n==================\n\n" if $LIST; then version=$(git describe --tags --abbrev=0 $(git rev-list --tags --max-count=1)) From 02950639817ca38183be5bb9ed91dd05b5644234 Mon Sep 17 00:00:00 2001 From: Phally Date: Sat, 5 May 2012 16:17:08 +0200 Subject: [PATCH 3/4] Updated readme; included the --tag switch. --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 1b8c603..04819bc 100644 --- a/Readme.md +++ b/Readme.md @@ -457,9 +457,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 From d3ad5d75c8f3621932a2f25fb9740eb7c042fb59 Mon Sep 17 00:00:00 2001 From: Phally Date: Sun, 3 Mar 2013 19:30:21 +0100 Subject: [PATCH 4/4] Adds the tag swtich to bash completion. --- etc/bash_completion.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/bash_completion.sh b/etc/bash_completion.sh index db68dfa..e6dbca7 100644 --- a/etc/bash_completion.sh +++ b/etc/bash_completion.sh @@ -5,7 +5,7 @@ _git_bug(){ } _git_changelog(){ - __gitcomp "--list" + __gitcomp "-l -t --list --tag" } _git_contrib(){