diff --git a/bin/commit-counter b/bin/commit-counter deleted file mode 100755 index a79a53d..0000000 --- a/bin/commit-counter +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python -import argparse -import datetime -import jinja2 -import os -import subprocess -import teamanalysis.git -import teamanalysis.repos -import teamanalysis.time -import webbrowser - -def _get_commits(repo, start, end): - abspath = '/Users/eliribble/src/{}/'.format(repo) - os.chdir(abspath) - command = [ - 'git', - 'log', - '--pretty=format:"%h %aI"', - '--after={}'.format(start.isoformat()), - '--before={}'.format(end.isoformat())] - output = subprocess.check_output(command) - return output - -def _show_summary(timepoint): - start, end = teamanalysis.time.get_checkpoint(timepoint) - results = {} - for repo in teamanalysis.repos.REPOSITORIES: - output = _get_commits(repo, start, end) - lines = output.split('\n') - results[repo] = len(lines) if output else 0 - #print("{0:<30}: {1}".format(repo, results[repo])) - print("{}\t{}\t{}".format(start.date().isoformat(), end.date().isoformat(), sum(results.values()))) - -def main(): - timepoint = datetime.datetime(2014, 1, 1, 0, 0, 1) - while timepoint < datetime.datetime.utcnow(): - _show_summary(timepoint) - timepoint = timepoint + datetime.timedelta(days=7) - -if __name__ == '__main__': - main() diff --git a/bin/overview-by-date b/bin/overview-by-date new file mode 100755 index 0000000..157c5cc --- /dev/null +++ b/bin/overview-by-date @@ -0,0 +1,126 @@ +#!/usr/bin/env python +import argparse +import datetime +import jinja2 +import logging +import os +import pprint +import re +import subprocess +import teamanalysis.git +import teamanalysis.repos +import teamanalysis.time +import webbrowser + +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): + abspath = _get_abspath(repo) + os.chdir(abspath) + command = ['git', 'checkout', 'master'] + subprocess.check_output(command, stderr=subprocess.STDOUT) + command = [ + 'git', + 'log', + '--pretty=format:"%h %aI"', + '--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 + +def _get_commit_sha_by_date(repo, timepoint): + abspath = _get_abspath(repo) + os.chdir(abspath) + command = [ + 'git', + 'rev-list', + '-n', + '1', + '--before="{}"'.format(timepoint.date().isoformat()), + 'master', + '--', + ] + LOGGER.debug("%s", ' '.join(command)) + output = subprocess.check_output(command) + output = output.strip() + LOGGER.debug("%s: %s", ' '.join(command), output) + return output + +def _git_checkout_by_date(repo, timepoint): + abspath = _get_abspath(repo) + commit = _get_commit_sha_by_date(repo, timepoint) + os.chdir(abspath) + command = [ + 'git', + 'checkout', + commit, + ] + output = subprocess.check_output(command, stderr=subprocess.STDOUT) + LOGGER.debug("Checked out %s at %s", repo, timepoint.date().isoformat()) + return output + +TEST_FUNCTION_PATTERN = re.compile(r'\s+