Script to generate ChangeLog file from commit log.
authorJeremy Stanley <fungi@yuggoth.org>
Sat, 29 May 2010 14:46:52 +0000 (14:46 +0000)
committerJeremy Stanley <fungi@yuggoth.org>
Sat, 29 May 2010 14:46:52 +0000 (14:46 +0000)
* bin/git2gch: New executable script for generating GNU-format
ChangeLog files from the Git commit log.

bin/git2gch [new file with mode: 0755]

diff --git a/bin/git2gch b/bin/git2gch
new file mode 100755 (executable)
index 0000000..70a8de6
--- /dev/null
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+u"""Generates potential ChangeLog file contents from commit messages."""
+
+# Copyright (c) 2010 Jeremy Stanley <fungi@yuggoth.org>. Permission
+# to use, copy, modify, and distribute this software is granted under
+# terms provided in the LICENSE file distributed with this software.
+
+# needs GitPython: http://gitorious.org/git-python
+import git, time
+
+copyright = """\
+Copyright (c) 2004-2010 Jeremy Stanley <fungi@yuggoth.org>. Permission to
+use, copy, modify, and distribute this software is granted under terms
+provided in the LICENSE file distributed with this software.
+
+"""
+
+emacsinfo = "\f" + """
+Local Variables:
+mode: change-log
+coding: utf-8
+left-margin: 8
+fill-column: 76
+version-control: never
+End:\
+"""
+
+generated = ""
+for commit in git.Repo().log():
+   header = "%s  %s  <%s>" % (
+      time.strftime("%Y-%m-%d %H:%M:%S UTC", commit.authored_date),
+      commit.author.name,
+      commit.author.email
+   )
+   comments = ""
+   for line in commit.message.split("\n")[1:]:
+      if line: line = "\t%s" % line
+      if line.startswith("\t*"): line = "\n%s" % line
+      comments += "%s\n" % line
+   generated += "%s\n%s\n" % ( header, comments)
+print( "%s%s%s" % (generated, copyright, emacsinfo) )