Show my commits next to the team commits

Makes it so I can track my own stuff separately from the rest of the
team. This requires a new config option, 'my_email'
This commit is contained in:
Eli Ribble 2015-08-05 15:06:56 -06:00
parent e6d35a85a9
commit 6c7f1642da
1 changed files with 17 additions and 11 deletions

View File

@ -7,6 +7,7 @@ import os
import pprint
import re
import subprocess
import teamanalysis.config
import teamanalysis.git
import teamanalysis.repos
import teamanalysis.time
@ -17,7 +18,7 @@ LOGGER = logging.getLogger('overview-by-date')
def _get_abspath(repo):
return '/Users/eliribble/src/teamanalysis/repos/{}/'.format(repo)
def _get_commit_count(repo, start, end):
def _get_commit_count(repo, start, end, my_email):
abspath = _get_abspath(repo)
os.chdir(abspath)
command = ['git', 'checkout', 'master']
@ -25,14 +26,16 @@ def _get_commit_count(repo, start, end):
command = [
'git',
'log',
'--pretty=format:"%h %aI"',
'--pretty=format:"%h %aI %aE"',
'--after={}'.format(start.isoformat()),
'--before={}'.format(end.isoformat())]
LOGGER.debug(" ".join(command))
output = subprocess.check_output(command)
lines = output.split('\n')
result = len(lines) if output else 0
return result
total = len(lines) if output else 0
my_lines = [line for line in lines if my_email in line]
mine = len(my_lines)
return {'total': total, 'mine': mine}
def _get_commit_sha_by_date(repo, timepoint):
abspath = _get_abspath(repo)
@ -92,12 +95,12 @@ def _get_test_count(repo, end):
_git_checkout_by_date(repo, end)
return _count_tests(repo)
def _show_summary(timepoint):
def _show_summary(timepoint, my_email):
start, end = teamanalysis.time.get_checkpoint(timepoint)
LOGGER.debug("Working %s to %s for %s", start, end, timepoint)
results = {}
for repo in teamanalysis.repos.REPOSITORIES:
commits = _get_commit_count(repo, start, end)
commits = _get_commit_count(repo, start, end, my_email)
tests = _get_test_count(repo, end)
results[repo] = {
'commits' : commits,
@ -107,19 +110,22 @@ def _show_summary(timepoint):
#pprint.pprint({k: v['tests'] for k, v in results.items()})
#pprint.pprint({k: v['commits'] for k, v in results.items()})
totals = {
'commits' : sum([result['commits'] for result in results.values()]),
'tests' : sum([result['tests'] for result in results.values() if result['tests']]),
'all_commits' : sum([result['commits']['total'] for result in results.values()]),
'my_commits' : sum([result['commits']['mine'] for result in results.values()]),
'tests' : sum([result['tests'] for result in results.values() if result['tests']]),
}
print("{}\t{}\t{}\t{}".format(start.date().isoformat(), end.date().isoformat(), totals['commits'], totals['tests']))
print("\t".join(map(str, [start.date().isoformat(), end.date().isoformat(), totals['all_commits'], totals['my_commits'], totals['tests']])))
def main():
logging.basicConfig()
LOGGER.setLevel(logging.INFO)
#LOGGER.setLevel(logging.DEBUG)
timepoint = datetime.datetime(2015, 5, 1, 0, 0, 1)
config = teamanalysis.config.get()
timepoint = datetime.datetime(2013, 12, 30, 0, 0, 1)
now = datetime.datetime.utcnow()
while timepoint < now + datetime.timedelta(days=7):
_show_summary(timepoint)
_show_summary(timepoint, config['my_email'])
timepoint = timepoint + datetime.timedelta(days=7)
if __name__ == '__main__':