From bb75f25beb530b9ca02c04b730da8a158694084b Mon Sep 17 00:00:00 2001 From: Heikki Hokkanen Date: Tue, 8 Jun 2010 16:56:38 +0300 Subject: [PATCH] Add options for limiting stats to begin..end range. Bit hackish and not fully supported, but -c commit_end=HEAD~10 allows limiting statistics generation to before HEAD~10 for example. --- gitstats | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/gitstats b/gitstats index 52daf2f..adce52e 100755 --- a/gitstats +++ b/gitstats @@ -34,6 +34,8 @@ conf = { 'style': 'gitstats.css', 'max_authors': 20, 'authors_top': 5, + 'commit_begin': '', + 'commit_end': '', } def getpipeoutput(cmds, quiet = False): @@ -56,6 +58,13 @@ def getpipeoutput(cmds, quiet = False): exectime_external += (end - start) return output.rstrip('\n') +def getcommitrange(defaultrange = '', end_only = False): + if len(conf['commit_end']) > 0: + if end_only or len(conf['commit_begin']) == 0: + return conf['commit_end'] + return '%s..%s' % (conf['commit_begin'], conf['commit_end']) + return defaultrange + def getkeyssortedbyvalues(dict): return map(lambda el : el[1], sorted(map(lambda el : (el[1], el[0]), dict.items()))) @@ -67,7 +76,7 @@ VERSION = 0 def getversion(): global VERSION if VERSION == 0: - VERSION = getpipeoutput(["git rev-parse --short HEAD"]).split('\n')[0] + VERSION = getpipeoutput(["git rev-parse --short %s" % getcommitrange('HEAD')]).split('\n')[0] return VERSION class DataCollector: @@ -161,7 +170,7 @@ class GitDataCollector(DataCollector): DataCollector.collect(self, dir) try: - self.total_authors = int(getpipeoutput(['git shortlog -s', 'wc -l'])) + self.total_authors = int(getpipeoutput(['git shortlog -s %s' % getcommitrange(), 'wc -l'])) except: self.total_authors = 0 #self.total_lines = int(getoutput('git-ls-files -z |xargs -0 cat |wc -l')) @@ -237,7 +246,7 @@ class GitDataCollector(DataCollector): # Collect revision statistics # Outputs "