blob: 39a532d82ebc325ce162ccfb969a1d7496ddb35e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#!/usr/bin/python
#
# Generate a database of commits and major versions they went into.
#
# committags [git-args]
#
# This code is part of the LWN git data miner.
#
# Copyright 2007-11 Eklektix, Inc.
# Copyright 2007-11 Jonathan Corbet <corbet@lwn.net>
#
# This file may be distributed under the terms of the GNU General
# Public License, version 2.
#
import sys
import re
import os
import pickle
git = 'git log --decorate '
if len(sys.argv) > 1:
git += ' '.join(sys.argv[1:])
input = os.popen(git, 'r')
DB = { }
Tag = 'None'
tagline = re.compile(r'^commit ([\da-f]+) .*tag: (v2\.6\.\d\d)')
commit = re.compile(r'^commit ([\da-f]+)')
for line in input.readlines():
if not line.startswith('commit'):
continue # This makes it go faster
m = tagline.search(line)
if m:
DB[m.group(1)] = Tag = m.group(2)
else:
m = commit.search(line)
if m:
DB[m.group(1)] = Tag
print 'Found %d commits' % (len(DB.keys()))
out = open('committags.db', 'w')
pickle.dump(DB, out)
out.close()
|