Add a couple of lines-per-version utilities
[git-dm.git] / committags
blobf1c8fc3106ee0e1299a6d6b1628f48ef76d0590e
1 #!/usr/bin/python
3 # Generate a database of commits and major versions they went into.
5 # committags [git-args]
7 import sys
8 import re
9 import os
10 import pickle
12 git = 'git log --decorate '
13 if len(sys.argv) > 1:
14 git += ' '.join(sys.argv[1:])
15 input = os.popen(git, 'r')
17 DB = { }
18 Tag = 'None'
20 tagline = re.compile(r'^commit ([\da-f]+) .*tag: (v2\.6\.\d\d)')
21 commit = re.compile(r'^commit ([\da-f]+)')
23 for line in input.readlines():
24 if not line.startswith('commit'):
25 continue # This makes it go faster
26 m = tagline.search(line)
27 if m:
28 DB[m.group(1)] = Tag = m.group(2)
29 else:
30 m = commit.search(line)
31 if m:
32 DB[m.group(1)] = Tag
34 print 'Found %d commits' % (len(DB.keys()))
35 out = open('committags.db', 'w')
36 pickle.dump(DB, out)
37 out.close()