Skip to content

Instantly share code, notes, and snippets.

@jhjaggars
Created July 20, 2017 22:54
Show Gist options
  • Save jhjaggars/976a9c84f440b35ff0231820228902d1 to your computer and use it in GitHub Desktop.
Save jhjaggars/976a9c84f440b35ff0231820228902d1 to your computer and use it in GitHub Desktop.
# git log --stat --name-only --pretty='hash:%H' | python p.py
import sys
from collections import defaultdict
import json
cur_hash = None
mapping = defaultdict(list)
for line in sys.stdin:
line = line.strip()
if not line:
continue
if line.startswith("hash:"):
cur_hash = line.split(":")[-1]
continue
mapping[line].append(cur_hash)
json.dump(mapping, sys.stdout, indent=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment