summaryrefslogtreecommitdiff
path: root/committags
blob: 2b7fb5b4c30dc7a74c540637d2df8bf8a195514d (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-8 LWN.net
# Copyright 2007-8 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()