[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] Add a new script to generate the ChangeLog files based on git history



* maint-tools/update-changelogs: The new script that updates ChangeLog files.
* README.translators: Adjust instructions for translators accordingly.
* ChangeLog, po/ChangeLog, man/ChangeLog, scripts/po/ChangeLog: Include
the tag required to auto-update the files (it contains the last
commit id at the time of the previous update).
---
 ChangeLog                     |    1 +
 README.translators            |   54 +++++++++-----------------
 maint-tools/update-changelogs |   86 +++++++++++++++++++++++++++++++++++++++++
 man/ChangeLog                 |    2 +
 po/ChangeLog                  |    2 +
 scripts/po/ChangeLog          |    1 +
 6 files changed, 110 insertions(+), 36 deletions(-)
 create mode 100755 maint-tools/update-changelogs

diff --git a/ChangeLog b/ChangeLog
index 2b703d5..28a41fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12097,3 +12097,4 @@ Thu Aug 25 11:46:27 1994  Ian Murdock  (imurdock@debra.debian.org)
 
 ChangeLog begins Thu Aug 25 11:46:27 1994 for dpkg 0.93.5.
 
+last: 99b8119fd26336dc6568cfc611523fd9ca4f71a6
diff --git a/README.translators b/README.translators
index 8a11e99..7171e00 100644
--- a/README.translators
+++ b/README.translators
@@ -1,35 +1,8 @@
 Translators, when adding/updating your translation files, please follow
 the following rules:
 
-* Update debian/changelog and one of po/ChangeLog, dselect/po/ChangeLog,
-  scripts/ChangeLog or man/ChangeLog:
-
-  - Beware the you should NOT update the main ChangeLog file
-    for translation updates. Use the ChangeLog in the relevant
-    subdirectory instead.
-
-  - The format of entries in the subdirectories' ChangeLog is strict:
-
-==========================================================
-2006-02-11  Christian Perrier  <bubulle@debian.org>
-
-	* fr.po: Updated to 1011t.
-==========================================================
-
-    Note the date format AND the DOUBLE SPACE between the date and the
-    translator's email address.
-
-    Note also the TAB character before the entry. NOT multiple spaces.
-
-    Also note that the update should mention the file statistics as
-    XXXtYYYfZZZu.
-
-    "XXXt" means "XXX translated strings".
-    "YYYf" means "YYY fuzzy strings strings".
-    "ZZZu" means "ZZZ untranslated strings".
-    YYY or ZZZ may be omitted if they are null.
-
-    This file contents MUST be encoded in UTF-8.
+* Update debian/changelog but do not touch to any other ChangeLog file,
+  they are auto-generated based on the git commit messages.
 
 * Format of entries in debian/changelog:
 
@@ -64,18 +37,27 @@ dpkg (1.13.15) unstable; urgency=low
 
 * Format of commit message
 
-  The formats above only apply to ChangeLog files and debian/changelog.
-  They do not apply to the commit message. Following recommendations
-  of http://wiki.debian.org/Teams/Dpkg/GitUsage you should start the
-  commit message with a summary line, followed by an empty line and a
-  a detailed/long description. For example:
+  Since ChangeLog files are auto-generated, it's important to properly
+  format the commit message. Following recommendations of
+  http://wiki.debian.org/Teams/Dpkg/GitUsage you should start the commit
+  message with a summary line, followed by an empty line and a a
+  detailed/long description. For example:
 
 ==========================================================
-Updated german translation of manual pages
+Updated german translation.
 
-	* man/po/fr.po: Updated to 1354t.
+* man/po/de.po: Updated to 1354t.
+* po/de.po: Updated to 1335t0f48u.
 ==========================================================
 
+  Note that the detailed description should mention the file statistics
+  as XXXtYYYfZZZu.
+
+  "XXXt" means "XXX translated strings".
+  "YYYf" means "YYY fuzzy strings strings".
+  "ZZZu" means "ZZZ untranslated strings".
+  YYY or ZZZ may be omitted if they are null.
+
 * Use of po/LINGUAS, dselect/po/LINGUAS or scripts/po/LINGUAS:
 
   When ADDING a new translation, don't forget adding the language to
diff --git a/maint-tools/update-changelogs b/maint-tools/update-changelogs
new file mode 100755
index 0000000..40ad322
--- /dev/null
+++ b/maint-tools/update-changelogs
@@ -0,0 +1,86 @@
+#!/bin/sh
+
+replace_files=1
+
+get_commit() {
+    grep ^last: $1 | awk '{print $2}'
+}
+
+display_new_entries() {
+    last="$1"
+    path="$2"
+    exclude_all="$3"
+    include_only="$4"
+    for rev in `git-rev-list $last.. $path`; do
+	date=$(git-log -n 1 --pretty='format:%ci' $rev | awk '{print $1}')
+	author=$(git-log -n 1 --pretty='format:%an  <%ae>' $rev)
+	message=$(git-log -n 1 --pretty='format:%s' $rev)
+	body=$(git-log -n 1 --pretty='format:%b' $rev)
+	if [ -n "$exclude_all" ]; then
+	    # Skip commits that only have changes in excluded directories
+	    # (except usual changelogs)
+	    changes=$(git-whatchanged -n 1 $rev | grep ^: | grep -v -E 'changelog$|ChangeLog$' | grep -v -E "$exclude_all")
+	    if [ -z "$changes" ]; then
+		continue
+	    fi
+	fi
+	if [ -n "$include_only" ]; then
+	    # Skip commits that also have changes outside of the listed directories
+	    # (except usual changelogs)
+	    changes=$(git-whatchanged -n 1 $rev | grep ^: | grep -v -E 'changelog$|ChangeLog$' | grep -v -E "$include_only")
+	    if [ -n "$changes" ]; then
+		continue
+	    fi
+
+	fi
+	echo "$date  $author"
+	echo ""
+	echo "	$message"
+	if [ "$body" != "<unknown>" ]; then
+	    echo ""
+	    echo "$body" | sed -e 's/^/	/'
+	fi
+	echo ""
+    done
+}
+
+newtip=$(git-show-ref --hash HEAD)
+
+# Update main changelog
+changelog=ChangeLog
+commit=$(get_commit $changelog)
+display_new_entries $commit "" "man/po/|scripts/po/|po/" >$changelog.new
+grep -v ^last: $changelog >>$changelog.new
+echo "last: $newtip" >>$changelog.new
+[ "$replace_files" = "1" ] && mv $changelog.new $changelog
+
+# Update po/changelog
+changelog=po/ChangeLog
+commit=$(get_commit $changelog)
+if [ -n "$commit" ]; then
+    display_new_entries $commit "po/" "" "man/|scripts/po/|po/" >$changelog.new
+    grep -v ^last: $changelog >>$changelog.new
+    echo "last: $newtip" >>$changelog.new
+    [ "$replace_files" = "1" ] && mv $changelog.new $changelog
+fi
+
+# Update man/ChangeLog
+changelog=man/ChangeLog
+commit=$(get_commit $changelog)
+if [ -n "$commit" ]; then
+    display_new_entries $commit "man/" "" "man/|scripts/po/|po/" >$changelog.new
+    grep -v ^last: $changelog >>$changelog.new
+    echo "last: $newtip" >>$changelog.new
+    [ "$replace_files" = "1" ] && mv $changelog.new $changelog
+fi
+
+# Update scripts/po/ChangeLog
+changelog=scripts/po/ChangeLog
+commit=$(get_commit $changelog)
+if [ -n "$commit" ]; then
+    display_new_entries $commit "scripts/po/" "" "man/|scripts/po/|po/">$changelog.new
+    grep -v ^last: $changelog >>$changelog.new
+    echo "last: $newtip" >>$changelog.new
+    [ "$replace_files" = "1" ] && mv $changelog.new $changelog
+fi
+
diff --git a/man/ChangeLog b/man/ChangeLog
index 608d771..57cf27f 100644
--- a/man/ChangeLog
+++ b/man/ChangeLog
@@ -1346,3 +1346,5 @@
 
 
 Older changes are documented in the top-level ChangeLog
+
+last: 99b8119fd26336dc6568cfc611523fd9ca4f71a6
diff --git a/po/ChangeLog b/po/ChangeLog
index dcbe49e..0264c94 100644
--- a/po/ChangeLog
+++ b/po/ChangeLog
@@ -1278,3 +1278,5 @@
 
 
 Older changes are documented in the top-level ChangeLog
+
+last: 99b8119fd26336dc6568cfc611523fd9ca4f71a6
diff --git a/scripts/po/ChangeLog b/scripts/po/ChangeLog
index e66da2a..0a122b5 100644
--- a/scripts/po/ChangeLog
+++ b/scripts/po/ChangeLog
@@ -170,3 +170,4 @@
 	* remove-potcdate.sin: Likewise.
 	* dpkg-dev.pot: Likewise.
 
+last: 99b8119fd26336dc6568cfc611523fd9ca4f71a6
-- 
1.5.3.7



Reply to: