Last active
August 29, 2015 14:14
-
-
Save benspaulding/b31b44b1a215ed342311 to your computer and use it in GitHub Desktop.
Quick-and-dirty script to get some data about a repo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Usage:: | |
pip install gitpython | |
cd <repo> | |
analyze-repo | |
""" | |
from __future__ import absolute_import, division, print_function, unicode_literals | |
import os | |
import git | |
def main(): | |
repo = git.Repo(os.getcwd()) | |
commits = repo.git.rev_list(all=True).splitlines() | |
tested_commits = [] | |
# Use git show to list the files changed in each commit | |
for commit in commits: | |
# We could get more precise with a regex, but 'in' is good enough & faster. | |
if 'test' in repo.git.show(commit, pretty='format:', name_only=True): | |
tested_commits.append(commit) | |
total_commits = len(commits) | |
commits_tested = len(tested_commits) | |
print('Total no. of commits: {0:>6,}'.format(total_commits)); | |
print('No. of commits that touch tests: {0:>6,}'.format(commits_tested)); | |
print('% of commits that touch tests: {0:>10.2%}'.format(commits_tested / total_commits)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment