Created
June 29, 2020 15:02
-
-
Save darabos/3d8a8bf790deda987efa3b6f726b08d4 to your computer and use it in GitHub Desktop.
Script for creating a graph of files from a Git history.
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
'''Creates a graph of source files connected by cooccurrence in commits. | |
git log --oneline --name-only | python git-to-graph.py > graph.csv | |
''' | |
import sys | |
import re | |
print('file1,file2,commit') | |
commit = None | |
files = [] | |
for line in sys.stdin: | |
if re.match('[0-9a-f]{9} ', line): | |
if commit and len(files) < 10: | |
for f1 in files: | |
for f2 in files: | |
if f1 != f2: | |
print(f'"{f1}","{f2}","{commit}"') | |
commit = line[10:].strip().replace('"', '\\"') | |
files = [] | |
else: | |
files.append(line.strip().replace('"', '\\"')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment