Last active
August 29, 2015 14:20
-
-
Save chooper/ce87ebd33e7196bc3921 to your computer and use it in GitHub Desktop.
Get the insertions and deletions for the last six months
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
#!/bin/bash | |
# Get the insertions and deletions for the last six months | |
git log --since 'last 6 months' --shortstat master > stats.log |
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 | |
from collections import defaultdict | |
from pprint import pprint | |
KEYS = { | |
'deletion(-)': 'deletions', | |
'deletions(-)': 'deletions', | |
'file changed': 'files changed', | |
'files changed': 'files changed', | |
'insertion(+)': 'insertions', | |
'insertions(+)': 'insertions'} | |
stats = defaultdict(lambda:0) | |
with open('stats.log', 'r') as f: | |
content = f.read() | |
for line in content.split("\n"): | |
line = line.strip() | |
shortstats = line.split(',') | |
for shortstat in shortstats: | |
if shortstat == '': | |
continue | |
shortstat = shortstat.strip() | |
shortstat_list = shortstat.split(' ', 1) | |
value, key = shortstat_list | |
stats[KEYS[key]] += int(value) | |
pprint(dict(stats)) | |
Usage:
./git-stats.sh > stats.log
./stats.py
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This worked nicely but there were some commits which were major outliers (like a two million line json file that was accidentally checked in)