7 # Makes a GNU-Style ChangeLog from a git repository
8 # Handles git-svn repositories also
10 # Arguments : same as for git log
13 def process_commit(lines, files):
21 lines = [x.strip() for x in lines if x.strip() and not x.startswith('git-svn-id')]
22 files = [x.strip() for x in files if x.strip()]
24 if l.startswith('* ') and ':' in l:
29 print top_line.strip()
39 cmd = ['git', 'log', '--pretty=format:--START-COMMIT--%H%n%ai %an <%ae>%n%n%s%n%b%n--END-COMMIT--',
40 '--date=short', '--name-only']
42 start_tag = find_start_tag()
45 cmd.extend(sys.argv[1:])
47 cmd.extend(["%s..HEAD" % (start_tag)])
49 p = subprocess.Popen(args=cmd, shell=False, stdout=subprocess.PIPE)
53 for lin in p.stdout.readlines():
54 if lin.startswith("--START-COMMIT--"):
56 process_commit(buf, files)
57 hash = lin[16:].strip()
59 rel = release_refs[hash]
60 print "=== release %d.%d.%d ===\n" % (int(rel[0]), int(rel[1]), int(rel[2]))
66 elif lin.startswith("--END-COMMIT--"):
68 elif filemode == True:
73 process_commit(buf, files)
76 # Populate the release_refs dict with the tags for previous releases
77 reltagre = re.compile("^([a-z0-9]{40}) refs\/tags\/RELEASE-([0-9]+)[-_.]([0-9]+)[-_.]([0-9]+)\^\{\}")
79 cmd = ['git', 'show-ref', '--tags', '--dereference']
80 p = subprocess.Popen(args=cmd, shell=False, stdout=subprocess.PIPE)
81 for lin in p.stdout.readlines():
82 match = reltagre.search (lin)
84 (sha, maj, min, nano) = match.groups()
85 release_refs[sha] = (maj, min, nano)
88 starttagre = re.compile("^([a-z0-9]{40}) refs\/tags\/CHANGELOG_START")
89 cmd = ['git', 'show-ref', '--tags']
90 p = subprocess.Popen(args=cmd, shell=False, stdout=subprocess.PIPE)
91 for lin in p.stdout.readlines():
92 match = starttagre.search (lin)
97 if __name__ == "__main__":