[Xfce4-commits] <xfburn:master> Fix up update-changelog.py to have nicer output.
David Mohr
noreply at xfce.org
Sat Feb 13 07:46:02 CET 2010
Updating branch refs/heads/master
to ce197d6ea04a08dd5537d285d2651f4471e0164c (commit)
from fb5f3bf850e98ae8b8dbd4226b58b10f80d34f18 (commit)
commit ce197d6ea04a08dd5537d285d2651f4471e0164c
Author: David Mohr <squisher at xfce.org>
Date: Fri Feb 12 23:24:54 2010 -0700
Fix up update-changelog.py to have nicer output.
update-changelog.py | 42 ++++++++++++++++++++++++++++++------------
1 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/update-changelog.py b/update-changelog.py
index ce69b68..8479a18 100755
--- a/update-changelog.py
+++ b/update-changelog.py
@@ -1,6 +1,13 @@
-#!/usr/bin/python
+#!/usr/bin/env python
# Copyright 2008 Marcus D. Hanwell <marcus at cryos.org>
+# 2010 David Mohr <squisher at xfce.org>
# Distributed under the terms of the GNU General Public License v2 or later
+#
+# Renamed from gitlog2changelog.py, from avogardro commit 8be9957e5b3b5675701ef2ed002aa9e718d4146e
+# Then adjusted to my needs:
+# * Keep formatting of commit messages, but skip empty lines
+# * Newline after the files
+# * Fix linebreak at 78 chars
import string, re, os
@@ -61,10 +68,11 @@ for line in fin:
elif len(line) == 4:
messageFound = True
else:
- if len(message) == 0:
- message = message + line.strip()
- else:
- message = message + " " + line.strip()
+ # strip space and tab but keep newlines
+ line = line.strip('\t ')
+ # swallow empty lines
+ if len(line) > 1:
+ message = message + ' ' + line
# If this line is hit all of the files have been stored for this commit
elif re.search('files changed', line) >= 0:
filesFound = True
@@ -91,24 +99,34 @@ for line in fin:
# Assemble the actual commit message line(s) and limit the line length
# to 80 characters.
- commitLine = "* " + files + ": " + message
+ commitLine = "* " + files + ":"
i = 0
commit = ""
while i < len(commitLine):
- if len(commitLine) < i + 78:
- commit = commit + "\n " + commitLine[i:len(commitLine)]
+ if i == 0:
+ indent = ' '
+ line_len = 76
+ else:
+ indent = ' '
+ line_len = 74
+
+ if len(commitLine) < i + line_len:
+ commit = commit + "\n" + indent + commitLine[i:len(commitLine)]
break
- index = commitLine.rfind(' ', i, i+78)
+ index = commitLine.rfind(' ', i, i+line_len)
+
if index > i:
- commit = commit + "\n " + commitLine[i:index]
+ commit = commit + "\n" + indent + commitLine[i:index]
i = index+1
else:
- commit = commit + "\n " + commitLine[i:78]
- i = i+79
+ commit = commit + "\n" + indent + commitLine[i:line_len]
+ i = i+line_len + 1
# Write out the commit line
fout.write(commit + "\n")
+ fout.write(message)
+
#Now reset all the variables ready for a new commit block.
authorFound = False
dateFound = False
More information about the Xfce4-commits
mailing list