-
-
Save exustash/cdeb11351f3e8b201ddcacd07916c23f to your computer and use it in GitHub Desktop.
python script for aggregating changes by folder.
This file contains hidden or 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
| import re | |
| # run ./git-most.sh > most.txt before this script | |
| # adjust whitelist var if you only want to see changes to a certain filetype/file/path | |
| most_changed_paths = {} | |
| whitelist = '' # '.yml' | |
| with open('most.txt') as f: | |
| for line in f.readlines(): | |
| split_line = line.split('\t') | |
| if len(split_line) == 1: | |
| continue # ignore malformed lines | |
| num = int(split_line[0]) | |
| path = split_line[1].strip() | |
| if whitelist: | |
| if whitelist not in path: | |
| continue | |
| match = re.fullmatch(r'(roles/[^/]+)/.*', path) | |
| if match: | |
| roleDir = match.group(1) | |
| if roleDir in most_changed_paths: | |
| most_changed_paths[roleDir] += num | |
| else: | |
| most_changed_paths[roleDir] = num | |
| sorted_most_changed_paths = sorted(most_changed_paths.items(), key=lambda kv: kv[1]) | |
| sorted_most_changed_paths.reverse() | |
| for path in sorted_most_changed_paths: | |
| print(path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment