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:
parent
e6d35a85a9
commit
6c7f1642da
|
@ -7,6 +7,7 @@ import os
|
||||||
import pprint
|
import pprint
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import teamanalysis.config
|
||||||
import teamanalysis.git
|
import teamanalysis.git
|
||||||
import teamanalysis.repos
|
import teamanalysis.repos
|
||||||
import teamanalysis.time
|
import teamanalysis.time
|
||||||
|
@ -17,7 +18,7 @@ LOGGER = logging.getLogger('overview-by-date')
|
||||||
def _get_abspath(repo):
|
def _get_abspath(repo):
|
||||||
return '/Users/eliribble/src/teamanalysis/repos/{}/'.format(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)
|
abspath = _get_abspath(repo)
|
||||||
os.chdir(abspath)
|
os.chdir(abspath)
|
||||||
command = ['git', 'checkout', 'master']
|
command = ['git', 'checkout', 'master']
|
||||||
|
@ -25,14 +26,16 @@ def _get_commit_count(repo, start, end):
|
||||||
command = [
|
command = [
|
||||||
'git',
|
'git',
|
||||||
'log',
|
'log',
|
||||||
'--pretty=format:"%h %aI"',
|
'--pretty=format:"%h %aI %aE"',
|
||||||
'--after={}'.format(start.isoformat()),
|
'--after={}'.format(start.isoformat()),
|
||||||
'--before={}'.format(end.isoformat())]
|
'--before={}'.format(end.isoformat())]
|
||||||
LOGGER.debug(" ".join(command))
|
LOGGER.debug(" ".join(command))
|
||||||
output = subprocess.check_output(command)
|
output = subprocess.check_output(command)
|
||||||
lines = output.split('\n')
|
lines = output.split('\n')
|
||||||
result = len(lines) if output else 0
|
total = len(lines) if output else 0
|
||||||
return result
|
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):
|
def _get_commit_sha_by_date(repo, timepoint):
|
||||||
abspath = _get_abspath(repo)
|
abspath = _get_abspath(repo)
|
||||||
|
@ -92,12 +95,12 @@ def _get_test_count(repo, end):
|
||||||
_git_checkout_by_date(repo, end)
|
_git_checkout_by_date(repo, end)
|
||||||
return _count_tests(repo)
|
return _count_tests(repo)
|
||||||
|
|
||||||
def _show_summary(timepoint):
|
def _show_summary(timepoint, my_email):
|
||||||
start, end = teamanalysis.time.get_checkpoint(timepoint)
|
start, end = teamanalysis.time.get_checkpoint(timepoint)
|
||||||
LOGGER.debug("Working %s to %s for %s", start, end, timepoint)
|
LOGGER.debug("Working %s to %s for %s", start, end, timepoint)
|
||||||
results = {}
|
results = {}
|
||||||
for repo in teamanalysis.repos.REPOSITORIES:
|
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)
|
tests = _get_test_count(repo, end)
|
||||||
results[repo] = {
|
results[repo] = {
|
||||||
'commits' : commits,
|
'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['tests'] for k, v in results.items()})
|
||||||
#pprint.pprint({k: v['commits'] for k, v in results.items()})
|
#pprint.pprint({k: v['commits'] for k, v in results.items()})
|
||||||
totals = {
|
totals = {
|
||||||
'commits' : sum([result['commits'] for result in results.values()]),
|
'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']]),
|
'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():
|
def main():
|
||||||
logging.basicConfig()
|
logging.basicConfig()
|
||||||
LOGGER.setLevel(logging.INFO)
|
LOGGER.setLevel(logging.INFO)
|
||||||
#LOGGER.setLevel(logging.DEBUG)
|
#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()
|
now = datetime.datetime.utcnow()
|
||||||
while timepoint < now + datetime.timedelta(days=7):
|
while timepoint < now + datetime.timedelta(days=7):
|
||||||
_show_summary(timepoint)
|
_show_summary(timepoint, config['my_email'])
|
||||||
timepoint = timepoint + datetime.timedelta(days=7)
|
timepoint = timepoint + datetime.timedelta(days=7)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue