Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor tweak to allow date ranges. #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions gitstats
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ conf = {
'linear_linestats': 1,
'project_name': '',
'processes': 8,
'start_date': ''
'start_date': '',
'end_date': '',
}

def getpipeoutput(cmds, quiet = False):
Expand All @@ -74,8 +75,13 @@ def getpipeoutput(cmds, quiet = False):

def getlogrange(defaultrange = 'HEAD', end_only = True):
commit_range = getcommitrange(defaultrange, end_only)
datesel = ''
if len(conf['start_date']) > 0:
return '--since="%s" "%s"' % (conf['start_date'], commit_range)
datesel = '--since="%s" %s' % (conf['start_date'], datesel)
if len(conf['end_date']) > 0:
datesel = '--until="%s" %s' % (conf['end_date'], datesel)
if (len(datesel) > 0):
commit_range = '%s "%s"' % (datesel, commit_range)
return commit_range

def getcommitrange(defaultrange = 'HEAD', end_only = False):
Expand Down Expand Up @@ -330,6 +336,9 @@ class GitDataCollector(DataCollector):
lines = getpipeoutput(['git rev-list --pretty=format:"%%at %%ai %%aN <%%aE>" %s' % getlogrange('HEAD'), 'grep -v ^commit']).split('\n')
for line in lines:
parts = line.split(' ', 4)
if (len(parts) != 4):
print 'Warning: failed to parse line "%s"' % line
continue
author = ''
try:
stamp = int(parts[0])
Expand Down Expand Up @@ -441,7 +450,12 @@ class GitDataCollector(DataCollector):
#Look up rev in cache and take info from cache if found
#If not append rev to list of rev to read from repo
for revline in revlines:
time, rev = revline.split(' ')
try:
time, rev = revline.split(' ')
except ValueError:
print 'Warning: failed to parse line "%s"' % line
continue

#if cache empty then add time and rev to list of new rev's
#otherwise try to read needed info from cache
if 'files_in_tree' not in self.cache.keys():
Expand Down