def log(self): """Parse git log history and return its content in a dictionary. :return: a dict representing git log entries """ return list( parse_commits(run_git_log(os.path.join(self.repo_path, '.git'))))
def git_log_report(git_dir=None, git_since=None): gitlog = git2json(run_git_log(git_dir, git_since)) gitlogjs = json.loads(gitlog) commits_with_git_push = 0 commits_with_gerrit_review = 0 names = dict() cnames = dict() for c in gitlogjs: try: chgid = c['message'].index('Change-Id') name = c['author']['email'] if name in cnames: cnames[name] += 1 else: cnames[name] = 1 commits_with_gerrit_review += 1 except: name = c['author']['email'] # print 'No change id for you', name if name in names: names[name] += 1 else: names[name] = 1 commits_with_git_push += 1 print 'Committers using git push:' never_used_gerrrit = 0 for name in names: print ' ', name, names[name], if name in cnames: print '(but used git review %s times)' % cnames[name] else: never_used_gerrrit += 1 print '' print 'Committers using gerrit (git review):' for name in cnames: print ' ', name, cnames[name] print 'Summary (since %s)' % git_since print ' Total commits:', len(gitlogjs) print ' Commits using gerrit (git review):', commits_with_gerrit_review print ' Commits using git push:', commits_with_git_push print ' Developers with at least one commit using gerrit:', len(cnames) print ' Developers with no commits using gerrit (but with one or more' \ ' git pushes):', never_used_gerrrit
import git2json as g import subprocess as s BENCH_REPO = '/home/tavish/capstone/nbdiff/.git' check_added = '1f52ff8b5acaa408948d7a73b07b9dd2554e863a' HEAD = check_added commits = g.parse_commits(g.run_git_log(extra_args=[HEAD + '..', '--']).read()) i = 0 for commit in commits: if i % 5 == 0: s.call(('git --git-dir=' + BENCH_REPO + ' checkout ' + commit).split()) benchmark_output = s.check_output(['python', 'benchmark.py', commit]) with open('results.csv', 'a') as out: out.write(benchmark_output) i += 1