Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Cherokee: commits

[3821] cherokee/trunk: Adds Git support to the ChangeLog file generation scripts.

 

 

Cherokee commits RSS feed   Index | Next | Previous | View Threaded


cherokee at cherokee-project

Nov 15, 2009, 1:24 PM

Post #1 of 1 (100 views)
Permalink
[3821] cherokee/trunk: Adds Git support to the ChangeLog file generation scripts.

Revision: 3821
http://svn.cherokee-project.com/changeset/3821
Author: alo
Date: 2009-11-15 22:24:18 +0100 (Sun, 15 Nov 2009)

Log Message:
-----------
Adds Git support to the ChangeLog file generation scripts.

Modified Paths:
--------------
cherokee/trunk/Makefile.am
cherokee/trunk/changelog-update.sh
cherokee/trunk/svnlog2changelog.py

Added Paths:
-----------
cherokee/trunk/developers.py
cherokee/trunk/gitlog2changelog.py

Modified: cherokee/trunk/Makefile.am
===================================================================
--- cherokee/trunk/Makefile.am 2009-11-15 19:23:34 UTC (rev 3820)
+++ cherokee/trunk/Makefile.am 2009-11-15 21:24:18 UTC (rev 3821)
@@ -77,7 +77,9 @@
SUNWcherokee.spec \
pam.d_cherokee \
cherokee.pc.in \
+developers.py \
svnlog2changelog.py \
+gitlog2changelog.py \
changelog-update.sh \
$(m4data_DATA) \
$(XMLS_PRE) \

Modified: cherokee/trunk/changelog-update.sh
===================================================================
--- cherokee/trunk/changelog-update.sh 2009-11-15 19:23:34 UTC (rev 3820)
+++ cherokee/trunk/changelog-update.sh 2009-11-15 21:24:18 UTC (rev 3821)
@@ -1,46 +1,97 @@
#!/bin/sh

-# Renders a ChangeLog file by using the Subversion commit logs
+# Renders a ChangeLog file by using the Subversion or Git commit logs
#
# Author: Alvaro Lopez Ortega <alvaro [at] alobbs>

-# FOR THE RECORD:
-# Commit log messages can be modified by running (replace $REV):
-# svn propedit svn:log --revprop -r$REV .
+TZ=UTC

+# The current ChangeLog file starts at revision number..
+FIRST_REV="3357"
+FIRST_ID="6cb69c1dc3c4ea293d05cc29f88e23548587be1f"
+
+# Local vars
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
test -z "$SVN" && SVN=svn
+test -z "$GIT" && GIT=git

-# The current ChangeLog file starts at revision number..
-FIRST_REV="3357"

-# Check what the latest revision of the ChangeLog file is
-if [ -e $srcdir/ChangeLog ]; then
- CHANGELOG_VERSION=`head -n 2 $srcdir/ChangeLog | tail -n 1 | awk {'print $2'} | sed 's|r||g; s|,||g'`
-else
- touch ChangeLog
-fi
+go_git()
+{
+ # Figure last ChangeLog entry
+ LAST_COMMIT_ID=`head -n 3 ChangeLog 2>/dev/null | grep 'svn=' | sed 's/ *svn=.* git=\(.*\)/\1/'`

-if [ x$CHANGELOG_VERSION = x ]; then
- CHANGELOG_VERSION=$FIRST_REV
-fi
+ if [ "x$LAST_COMMIT_ID" = "x" ]; then
+ LAST_COMMIT_ID="$FIRST_ID"
+ echo " * Creating a brand new ChangeLog file"
+ else
+ echo " * Last commit in the ChangeLog: $LAST_COMMIT_ID"
+ fi

-# Find the latest revision in the SVN
-SVN_VERSION=`svnversion -c . | sed -e 's/^[^:]*://;s/[A-Za-z]//'`
-if [ x$SVN_VERSION = x ]; then
- echo
- echo "WARNING: Couldn't get svn revision number."
- echo " Is svn or the .svn directories missing?"
- echo
+ # New log
+ echo " * Appending commits since: $LAST_COMMIT_ID"
+ $GIT log --stat --no-merges --date=short $LAST_COMMIT_ID..HEAD | python $srcdir/gitlog2changelog.py > $srcdir/ChangeLog.new
+
+ if test ! -s $srcdir/ChangeLog.new ; then
+ echo " * Changelog is already up-to-date."
+ else
+ if test -f $srcdir/ChangeLog ; then
+ echo " * Merging new entries.."
+ mv $srcdir/ChangeLog $srcdir/ChangeLog.prev
+ cat $srcdir/ChangeLog.new $srcdir/ChangeLog.prev > ChangeLog
+ else
+ echo " * No previous entries.."
+ mv $srcdir/ChangeLog.new $srcdir/ChangeLog
+ fi
+ fi
+
+ echo " * Cleaning up"
+ rm -f $srcdir/ChangeLog.new $srcdir/ChangeLog.prev
+}
+
+
+go_svn()
+{
+ # FOR THE RECORD:
+ # Commit log messages can be modified by running (replace $REV):
+ # svn propedit svn:log --revprop -r$REV .
+
+ # Check what the latest revision of the ChangeLog file is
+ if [ -e $srcdir/ChangeLog ]; then
+ CHANGELOG_VERSION=`head -n 2 $srcdir/ChangeLog | tail -n 1 | awk {'print $2'} | sed 's|r||g; s|,||g'`
+ else
+ touch ChangeLog
+ fi
+
+ if [ x$CHANGELOG_VERSION = x ]; then
+ CHANGELOG_VERSION=$FIRST_REV
+ fi
+
+ # Find the latest revision in the SVN
+ SVN_VERSION=`svnversion -c . | sed -e 's/^[^:]*://;s/[A-Za-z]//'`
+ if [ x$SVN_VERSION = x ]; then
+ echo
+ echo "WARNING: Couldn't get svn revision number."
+ echo " Is svn or the .svn directories missing?"
+ echo
+ else
+ if [ x$SVN_VERSION = x$CHANGELOG_VERSION ]; then
+ echo "ChangeLog is already up-to-date."
+ else
+ echo "Updating ChangeLog from version $CHANGELOG_VERSION to $SVN_VERSION..."
+ mv $srcdir/ChangeLog $srcdir/ChangeLog.prev
+ $SVN log -v --xml -r $SVN_VERSION:$((CHANGELOG_VERSION+1)) $srcdir | python $srcdir/svnlog2changelog.py > $srcdir/ChangeLog
+ cat $srcdir/ChangeLog.prev >> $srcdir/ChangeLog
+ rm -f $srcdir/ChangeLog.prev
+ fi
+ fi
+}
+
+
+# main
+if [ -d .git ]; then
+ go_git
else
- if [ x$SVN_VERSION = x$CHANGELOG_VERSION ]; then
- echo "ChangeLog is already up-to-date."
- else
- echo "Updating ChangeLog from version $CHANGELOG_VERSION to $SVN_VERSION..."
- mv $srcdir/ChangeLog $srcdir/ChangeLog.prev
- TZ=UTC $SVN log -v --xml -r $SVN_VERSION:$((CHANGELOG_VERSION+1)) $srcdir | python $srcdir/svnlog2changelog.py > $srcdir/ChangeLog
- cat $srcdir/ChangeLog.prev >> $srcdir/ChangeLog
- rm $srcdir/ChangeLog.prev
- fi
+ go_svn
fi

Added: cherokee/trunk/developers.py
===================================================================
--- cherokee/trunk/developers.py (rev 0)
+++ cherokee/trunk/developers.py 2009-11-15 21:24:18 UTC (rev 3821)
@@ -0,0 +1,7 @@
+DEVELOPERS = {
+ 'alo' : "Alvaro Lopez Ortega <alvaro [at] octality>",
+ 'aperez' : "Antonio Perez <aperez [at] skarcha>",
+ 'ion' : "Jonathan Hernandez <ion [at] suavizado>",
+ 'taher' : "Taher Shihadeh <taher [at] unixwars>",
+ 'robertounbit' : "Roberto De Ioris <roberto [at] unbit>"
+}

Added: cherokee/trunk/gitlog2changelog.py
===================================================================
--- cherokee/trunk/gitlog2changelog.py (rev 0)
+++ cherokee/trunk/gitlog2changelog.py 2009-11-15 21:24:18 UTC (rev 3821)
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+
+##
+## Cherokee SVNlog2Changelog script
+##
+## Copyright: Alvaro Lopez Ortega <alvaro [at] alobbs>
+## Licensed: GPL v2
+##
+
+import re
+import time
+
+from sys import stdin
+from developers import DEVELOPERS
+
+
+def get_commits():
+ chunk = ''
+ commits = []
+
+ while True:
+ line = stdin.readline()
+ if not line:
+ break
+ elif line.startswith("commit"):
+ if not chunk:
+ chunk += "%s" %(line)
+ else:
+ commits.append (chunk)
+ chunk = "%s" %(line)
+ else:
+ chunk += "%s" %(line)
+
+ if chunk:
+ commits.append(chunk)
+
+ return commits
+
+
+def format_body (body):
+ result = ""
+ prev_blank = False
+
+ for line in body.splitlines():
+ if "git-svn-id: svn://" in line:
+ continue
+
+ if not line.strip():
+ if prev_blank:
+ continue
+ else:
+ result += "%s\n"%(line)
+ prev_blank = True
+ else:
+ result += "%s\n"%(line)
+ prev_blank = False
+
+ return result
+
+
+def do_parse():
+ for entry in get_commits():
+ commit = re.findall(r"commit (\w+)", entry)[0]
+ author = re.findall(r"Author: +(.+) \<", entry)[0]
+ date = re.findall(r"Date: +(.+)", entry)[0]
+ svn_id = re.findall(r"git-svn-id: svn://cherokee-project.com/cherokee/trunk@(.+) ", entry)[0]
+
+ header_end = entry.index('\n\n')
+ if header_end == -1:
+ continue
+
+ print "%s %s" %(date, DEVELOPERS[author])
+ print " svn=%s git=%s" %(svn_id, commit)
+ print
+ print format_body(entry[header_end + 2:])
+
+
+if __name__ == "__main__":
+ do_parse()

Modified: cherokee/trunk/svnlog2changelog.py
===================================================================
--- cherokee/trunk/svnlog2changelog.py 2009-11-15 19:23:34 UTC (rev 3820)
+++ cherokee/trunk/svnlog2changelog.py 2009-11-15 21:24:18 UTC (rev 3821)
@@ -8,17 +8,12 @@
##

import time
-from sys import stdin
import xml.dom.minidom

-DEVELOPERS = {
- 'alo' : "Alvaro Lopez Ortega <alvaro [at] octality>",
- 'aperez' : "Antonio Perez <aperez [at] skarcha>",
- 'ion' : "Jonathan Hernandez <ion [at] suavizado>",
- 'taher' : "Taher Shihadeh <taher [at] unixwars>",
- 'robertounbit' : "Roberto De Ioris <roberto [at] unbit>"
-}
+from sys import stdin
+from developers import DEVELOPERS

+
def get_text (nodelist):
for node in nodelist:
if node.nodeType == node.TEXT_NODE:

Cherokee commits RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.