docs: added links to relted site for Bpfc and trafgen/netsniff-ng
[netsniff-ng.git] / contrib / devel / git / git2cl.py
blobd1923b5d6e9a343529b131ff49e02bb4ddfef88c
1 #!/usr/bin/python
3 # Copyright 2008 Marcus D. Hanwell <marcus@cryos.org>
4 # Copyright 2010 Daniel Borkmann <daniel@netsniff-ng.org>
6 # Distributed under the terms of the GNU General Public License v2 or later.
8 import string, re, os
10 fin = os.popen('git log --summary --stat --no-merges --date=short', 'r')
11 fout = open('CHANGELOG', 'w')
13 authorFound = False
14 dateFound = False
15 messageFound = False
16 changesFound = False
17 message = ""
18 changes = ""
19 messageNL = False
20 prevAuthorLine = ""
22 for line in fin:
23 if string.find(line, 'commit') >= 0:
24 authorFound = False
25 dateFound = False
26 messageFound = False
27 changesFound = False
28 messageNL = False
29 message = ""
30 continue
31 elif re.match('Author:', line) >=0:
32 authorList = re.split(': ', line, 1)
33 author = authorList[1]
34 author = author[0:len(author)-1]
35 authorFound = True
36 elif re.match('Date:', line) >= 0:
37 dateList = re.split(': ', line, 1)
38 date = dateList[1]
39 date = date[0:len(date)-1]
40 dateFound = True
41 elif re.match('\s+git-svn-id:', line) >= 0:
42 continue
43 elif re.search('Signed-off-by', line) >= 0:
44 continue
45 elif re.search('.+files changed.+insertions.+deletions.+', line) \
46 >= 0:
47 changes = "\n :" + line[:-1]
48 changesFound = True
49 elif authorFound & dateFound & messageFound == False:
50 if len(line) == 1:
51 if messageNL:
52 messageFound = True
53 else:
54 messageNL = True
55 elif len(line) == 4:
56 messageFound = True
57 else:
58 if len(message) == 0:
59 message = message + line.strip()
60 else:
61 message = message + " " + line.strip()
62 elif authorFound & dateFound & messageFound:
63 authorLine = date + " " + author + changes
64 if len(prevAuthorLine) == 0:
65 fout.write(authorLine + "\n\n")
66 elif authorLine == prevAuthorLine:
67 pass
68 else:
69 fout.write("\n" + authorLine + "\n\n")
70 commitLine = message
71 i = 0
72 first = False
73 commit = " * "
74 while i < len(commitLine):
75 if len(commitLine) < i + 72:
76 commit = commit + \
77 commitLine[i:len(commitLine)] + \
78 "\n "
79 break
80 index = commitLine.rfind(' ', i, i + 72)
81 if index > i:
82 commit = commit + commitLine[i:index] + \
83 "\n "
84 i = index + 1
85 else:
86 commit = commit + commitLine[i:72] + \
87 "\n "
88 i = i + 73
89 commit = commit[:-5]
90 fout.write(commit + "\n")
91 authorFound = False
92 dateFound = False
93 messageFound = False
94 changesFound = False
95 messageNL = False
96 message = ""
97 prevAuthorLine = authorLine
99 fin.close()
100 fout.close()