[ofa-general] [PATCH] management/gen_chlog.sh: simple ChangeLog generator
Sasha Khapyorsky
sashak at voltaire.com
Sun Jul 22 14:51:54 PDT 2007
This gen_chlog.sh scripts generates ChangeLog (from git logs) for
specified subdirectory or for whole tree if "." is used. This supports
ChangleLog and spec file formats.
The script can be used during tarballs generation by make.dist or
'make dist'.
Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
gen_chlog.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 68 insertions(+), 0 deletions(-)
create mode 100755 gen_chlog.sh
diff --git a/gen_chlog.sh b/gen_chlog.sh
new file mode 100755
index 0000000..9d60081
--- /dev/null
+++ b/gen_chlog.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+usage()
+{
+ echo "Usage: $0 [--spec] <target>"
+ exit 2
+}
+
+test -z "$1" && usage
+
+if [ "$1" = "--spec" ] ; then
+ spec_format=1
+ shift
+ test -z "$1" && usage
+fi
+
+TARGET=$1
+
+GIT_DIR=`git-rev-parse --git-dir 2>/dev/null`
+
+test -z "$GIT_DIR" && usage
+
+
+export GIT_DIR
+export GIT_PAGER=""
+export PAGER=""
+
+
+mkchlog()
+{
+ target=$1
+ format=$2
+
+ prev_tag=""
+
+ for tag in `git-tag -l $target` ; do
+ obj=`git-cat-file tag $tag | awk '/^object /{print $2}'`
+ base=`git-merge-base $obj HEAD`
+ if [ -z "$base" -o "$base" != $obj ] ; then
+ continue
+ fi
+ all_vers="$prev_tag$tag $all_vers"
+ prev_tag=$tag..
+ done
+
+ if [ -z "$prev_tag" ] ; then
+ all_vers=HEAD
+ else
+ all_vers="${prev_tag}HEAD $all_vers"
+ fi
+
+ for ver in $all_vers ; do
+ ver_name=`echo $ver | sed -e 's/^.*\.\.//'`
+ echo "* Version: $ver_name"
+ echo ""
+ git-log --no-merges "${format}" $ver -- $target
+ prev_t=$tag..
+ done
+}
+
+
+if [ -z "$spec_format" ] ; then
+ mkchlog $TARGET --pretty=format:"commit %H%n%ad %an%n%n %s%n"
+else
+ echo "%changelog"
+ mkchlog $TARGET --pretty=format:"- %ad %an: %s"
+ echo ""
+fi
--
1.5.3.rc2.29.gc4640f
More information about the general
mailing list