From 803b69beb391083eaf3044c29400d070f5478f62 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Sun, 13 May 2012 14:14:29 +0300 Subject: [PATCH] Generate ChangeLog automatically from git log. --- .gitignore | 1 + ChangeLog => ChangeLog.svn | 0 Makefile.am | 18 +++++++++ git2chg.awk | 76 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+) rename ChangeLog => ChangeLog.svn (100%) create mode 100644 git2chg.awk diff --git a/.gitignore b/.gitignore index 3b9c9c3..b03bc71 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ .gdbinit .libs ABOUT-NLS +ChangeLog INSTALL Makefile Makefile.in diff --git a/ChangeLog b/ChangeLog.svn similarity index 100% rename from ChangeLog rename to ChangeLog.svn diff --git a/Makefile.am b/Makefile.am index 13c2a35..6d7d50f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -35,3 +35,21 @@ SUBDIRS = \ pam_sql\ $(LDAPHOME_DIR)\ pamck + +EXTRA_DIST=ChangeLog.svn +# Name of the previous ChangeLog file. +prev_change_log = ChangeLog.svn +# Start Git ChangeLog from this date. +gen_start_date = 2012-05-13 + +.PHONY: ChangeLog +ChangeLog: + $(AM_V_GEN)if test -d .git; then \ + git log --pretty='format:%ct %an <%ae>%n%n%s%n%n%b%n' | \ + awk -f $(top_srcdir)/git2chg.awk \ + -vsince="$(gen_start_date)" -vappend="$(prev_change_log)" \ + > ChangeLog.tmp; \ + cmp ChangeLog ChangeLog.tmp > /dev/null 2>&1 || \ + mv ChangeLog.tmp ChangeLog; \ + rm -f ChangeLog.tmp; \ + fi diff --git a/git2chg.awk b/git2chg.awk new file mode 100644 index 0000000..166f6b2 --- /dev/null +++ b/git2chg.awk @@ -0,0 +1,76 @@ +# This file is part of grecs +# Copyright (C) 2007, 2009-2012 Sergey Poznyakoff +# +# Grecs is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Grecs is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Grecs. If not, see . + +BEGIN { + if (since) + split(since,since_a,"-") +} + +function timeok(t, a) { + if (!since) + return 1 + split(t,a,"-") + if (a[1] < since_a[1]) + return 0 + if (a[1] >= since_a[1]) + return 1 + if (a[2] < since_a[2]) + return 0 + if (a[2] >= since_a[2]) + return 1 + return a[3] >= since_a[3] +} + +/^[0-9]+ .* +<[^>]+>/ { + s = strftime("%F", $1) + if (!timeok(s)) + exit + sub(/^[0-9]+ +/,"") + if (s == datestr && author == $0) + next + datestr = s + author = $0 + if (runlen) { runlen = 0; print "" } + printf("%s %s\n", datestr, author) + next +} +/^Signed-off-by:/ { next } +/^git-svn-id:/ { next } +/^$/ { next } +NF==0 { + runlen++ + next +} +{ if (runlen) { runlen = 0; print "" } + print "\t" $0 } + +END { + if (append) { + print "" + while ((getline < append) > 0) { + if (match($0, /^Local *Variables:/)) + break + print + } + } + print "\f" + # Make sure Emacs won't recognize this line: + print "Local", "Variables:" + print "mode: change-log" + print "version-control: never" + print "buffer-read-only: t" + print "End:" +}