root/cherokee/trunk/gitlog2changelog.py

Revision 4108, 1.9 kB (checked in by alo, 2 months ago)

Fixes the ChangeLog converter so it works with SVN branches as well.

Line 
1 #!/usr/bin/env python
2
3 ##
4 ## Cherokee SVNlog2Changelog script
5 ##
6 ## Copyright: Alvaro Lopez Ortega <alvaro@alobbs.com>
7 ## Licensed: GPL v2
8 ##
9
10 import re
11 import sys
12 import time
13
14 from sys import stdin
15 from developers import DEVELOPERS
16
17
18 def get_commits():
19     chunk   = ''
20     commits = []
21
22     while True:
23         line = stdin.readline()
24         if not line:
25             break
26         elif line.startswith("commit"):
27             if not chunk:
28                 chunk += "%s" %(line)
29             else:
30                 commits.append (chunk)
31                 chunk = "%s" %(line)
32         else:
33             chunk += "%s" %(line)
34
35     if chunk:
36         commits.append(chunk)
37
38     return commits
39
40
41 def format_body (body):
42     result     = ""
43     prev_blank = False
44
45     for line in body.splitlines():
46         if "git-svn-id: svn://" in line:
47             continue
48
49         if not line.strip():
50             if prev_blank:
51                 continue
52             else:
53                 result += "%s\n"%(line)
54                 prev_blank = True
55         else:
56             result += "%s\n"%(line)
57             prev_blank = False
58
59     return result
60
61
62 def do_parse():
63     for entry in get_commits():
64         commit = re.findall(r"commit (\w+)", entry)[0]
65         author = re.findall(r"Author: +(.+) \<", entry)[0]
66         date   = re.findall(r"Date: +(.+)", entry)[0]
67
68         if not "git-svn-id:" in entry:
69             print >> sys.stderr, "Unpushed commit: %s, %s - %s" % (author, date, commit)
70             continue
71
72         svn_id = re.findall(r"git-svn-id: svn://cherokee-project.com/.+@(.+) ", entry)[0]
73
74         header_end = entry.index('\n\n')
75         if header_end == -1:
76             continue
77
78         print "%s  %s" %(date, DEVELOPERS[author])
79         print "            svn=%s git=%s" %(svn_id, commit)
80         print
81         print format_body(entry[header_end + 2:])
82
83
84 if __name__ == "__main__":
85     do_parse()
Note: See TracBrowser for help on using the browser.