From fabb2c55418ba2deb54a045d2f143ce1a402ecf1 Mon Sep 17 00:00:00 2001 From: Damian Krzeminski Date: Sun, 15 Feb 2015 18:57:07 -0500 Subject: [PATCH] changelog: add git-config support for format and log options (1) make format configurable you can change the default changelog format by configuring changelog.format git variable for example: git config changelog.format '- %s (%ae)' gives you something like that: - Merge pull request #298 from timfeirg/master (hemanth.hm@gmail.com) - remove stuff from readme & form a list (kkcocogogo@gmail.com) see git-log man for more examples (2) make log options configurable set `changelog.opts` to influence the way changelogs are generated git config changelog.opts --no-merges or: git config changelog.opts --first-parent fixes #285 also: - delay calculating HEAD until needed - remove extra line before header --- bin/git-changelog | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/bin/git-changelog b/bin/git-changelog index 7c0cdd9..452157a 100755 --- a/bin/git-changelog +++ b/bin/git-changelog @@ -3,7 +3,9 @@ FILE="" LIST=false TAG="n.n.n" -GIT_LOG_OPTS="" +GIT_LOG_OPTS=$(git config changelog.opts) +GIT_LOG_FORMAT=$(git config changelog.format) +test -z "$GIT_LOG_FORMAT" && GIT_LOG_FORMAT=' * %s' EDITOR=$(git var GIT_EDITOR) while [ "$1" != "" ]; do @@ -25,22 +27,22 @@ while [ "$1" != "" ]; do shift done -DATE=`date +'%Y-%m-%d'` -HEAD="\n$TAG / $DATE\n" -for i in $(seq 5 ${#HEAD}); do HEAD="$HEAD="; done -HEAD="$HEAD\n\n" - if $LIST; then lasttag=$(git rev-list --tags --max-count=1 2>/dev/null) version=$(git describe --tags --abbrev=0 $lasttag 2>/dev/null) if test -z "$version"; then - git log $GIT_LOG_OPTS --pretty="format: * %s" + git log $GIT_LOG_OPTS --pretty=format:"${GIT_LOG_FORMAT}" else - git log $GIT_LOG_OPTS --pretty="format: * %s" $version.. + git log $GIT_LOG_OPTS --pretty=format:"${GIT_LOG_FORMAT}" $version.. fi | sed 's/^ \* \*/ */g' exit fi +DATE=`date +'%Y-%m-%d'` +HEAD="\n$TAG / $DATE\n" +for i in $(seq 5 ${#HEAD}); do HEAD="$HEAD="; done +HEAD="$HEAD\n\n" + CHANGELOG=$FILE if test "$CHANGELOG" = ""; then CHANGELOG=`ls | egrep 'change|history' -i|head -n1` @@ -51,7 +53,7 @@ fi tmp=`mktemp -t $(basename $0).XXX` printf "$HEAD" > $tmp git-changelog $GIT_LOG_OPTS --list >> $tmp -printf '\n\n' >> $tmp +printf '\n' >> $tmp if [ -f $CHANGELOG ]; then cat $CHANGELOG >> $tmp; fi mv -f $tmp $CHANGELOG test -n "$EDITOR" && $EDITOR $CHANGELOG