diff options
-rw-r--r-- | database.py | 1 | ||||
-rwxr-xr-x | firstlast | 63 | ||||
-rw-r--r-- | gitlog.py | 17 |
3 files changed, 71 insertions, 10 deletions
diff --git a/database.py b/database.py index fcf07af..a0cd736 100644 --- a/database.py +++ b/database.py @@ -118,7 +118,6 @@ def LookupStoreHacker(name, email, mapunknown = False): def AllHackers (): return HackersByID.values () -# return [h for h in HackersByID.values ()] # if (h.added + h.removed) > 0] def DumpDB (): out = open ('database.dump', 'w') diff --git a/firstlast b/firstlast new file mode 100755 index 0000000..0230683 --- /dev/null +++ b/firstlast @@ -0,0 +1,63 @@ +#!/usr/bin/pypy +# -*- python -*- +# +# Crank through the log looking at when developers did their first and +# last patches. +# +# git log | firstlast -v versiondb +# +import argparse, pickle +import sys +import gitlog +import database + +# +# Arg processing +# +def SetupArgs(): + p = argparse.ArgumentParser() + p.add_argument('-v', '--versiondb', help = 'Version database file', + required = False, default = 'committags.db') + return p.parse_args() + +args = SetupArgs() +VDB = pickle.load(open(args.versiondb, 'r')) + +Firsts = { } +Lasts = { } + +patch = gitlog.grabpatch(sys.stdin) +while patch: + try: + v = VDB[patch.commit] + except KeyError: + print 'Funky commit', patch.commit + continue + try: + x = patch.author.patches + except AttributeError: + print 'Attr err', patch.commit + continue + # + # The first patch we see is the last they committed, since git + # lists things in backwards order. + # + if len(patch.author.patches) == 0: + patch.author.lastvers = v + try: + Lasts[v].append(patch.author) + except KeyError: + Lasts[v] = [patch.author] + patch.author.firstvers = v + patch.author.addpatch(patch) + patch = gitlog.grabpatch(sys.stdin) + +for h in database.AllHackers(): + if len(h.patches) > 0: + try: + Firsts[h.firstvers].append(h) + except KeyError: + Firsts[h.firstvers] = [h] + +for v in Lasts.keys(): + print v, len(Firsts[v]), len(Lasts[v]) @@ -14,12 +14,6 @@ import re # # Someday. # -InputFile = None - -def SetInput(input): - global InputFile - InputFile = input - SavedLine = '' def getline(input): @@ -61,6 +55,10 @@ S_DONE = 4 # def get_header(patch, line, input): if line == '': + if patch.author == '': + print 'Funky auth line in', patch.commit + patch.author = database.LookupStoreHacker('Unknown', + 'unknown@hacker.net') return S_DESC m = patterns['author'].match(line) if m: @@ -73,10 +71,10 @@ def get_desc(patch, line, input): print 'Missing desc in', patch.commit return S_CHANGELOG patch.desc = line - #print 'desc', patch.desc line = getline(input) - if line: - print 'Weird post-desc line in', patch.commit + while line: + patch.desc += line + line = getline(input) return S_CHANGELOG tagline = re.compile(r'^\s+(([-a-z]+-by)|cc):.*@.*$', re.I) @@ -140,6 +138,7 @@ class patch: self.author = '' self.signoffs = [ ] self.othertags = 0 + self.added = self.removed = 0 def grabpatch(input): # |