From 780c0fd57ec83d40ea511f2fce171c1ea378ae34 Mon Sep 17 00:00:00 2001 From: Sylvain Joyeux Date: Thu, 29 May 2014 22:01:23 +0200 Subject: [PATCH] implement a way to limit the statistics to commits after a start date This is really useful when computing statistics over a set of repositories, where some repositories are much older than other. Signed-off-by: Heikki Hokkanen --- gitstats | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/gitstats b/gitstats index 9e639df..0b444b7 100755 --- a/gitstats +++ b/gitstats @@ -48,6 +48,7 @@ conf = { 'project_name': '', 'merge_authors': {}, 'processes': 8, + 'start_date': '' } def getpipeoutput(cmds, quiet = False): @@ -72,6 +73,12 @@ def getpipeoutput(cmds, quiet = False): exectime_external += (end - start) return output.rstrip('\n') +def getlogrange(defaultrange = 'HEAD', end_only = True): + commit_range = getcommitrange(defaultrange, end_only) + if len(conf['start_date']) > 0: + return '--since=%s %s' % (conf['start_date'], commit_range) + return commit_range + def getcommitrange(defaultrange = 'HEAD', end_only = False): if len(conf['commit_end']) > 0: if end_only or len(conf['commit_begin']) == 0: @@ -280,7 +287,7 @@ class GitDataCollector(DataCollector): def collect(self, dir): DataCollector.collect(self, dir) - self.total_authors += int(getpipeoutput(['git shortlog -s %s' % getcommitrange(), 'wc -l'])) + self.total_authors += int(getpipeoutput(['git shortlog -s %s' % getlogrange(), 'wc -l'])) #self.total_lines = int(getoutput('git-ls-files -z |xargs -0 cat |wc -l')) # tags @@ -323,7 +330,7 @@ class GitDataCollector(DataCollector): # Collect revision statistics # Outputs "