Last active
February 15, 2020 01:46
-
-
Save iamaziz/1019e5a9261132ac2a9a to your computer and use it in GitHub Desktop.
See the total size growth between a number of consecutive commits in your git project. Based on http://stackoverflow.com/questions/10845051/git-show-total-file-size-difference-between-two-commits/10847242#10847242
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
#!/usr/bin/env python | |
""" | |
Usage: | |
$ git-file-size-growth <NUM_COMMIT> | |
note: | |
- Put `git-file-size-growth` somewhere in your PATH along with `git-file-size-diff` | |
# see `git-file-size-diff` at: http://stackoverflow.com/questions/10845051/git-show-total-file-size-difference-between-two-commits/10847242#10847242 | |
""" | |
import os | |
logs_history = os.popen('git log --oneline').read() | |
logs = logs_history.split('\n') | |
log_ids = [l.split(' ')[0] for l in logs if l is not ''] | |
total_commit = len(log_ids) - 1 | |
if total_commit == 0: | |
print("No git COMMIT found!") | |
exit() | |
# get numbe of commit | |
import argparse | |
parser = argparse.ArgumentParser() | |
parser.add_argument("NUM_COMMIT", help="number of commits to show difference in size growth, MAX: {}".format(total_commit), type=int) | |
args = parser.parse_args() | |
length = args.NUM_COMMIT | |
if length > total_commit: | |
print('NUM_COMMIT exceeds the limit: {}'.format(total_commit)) | |
exit() | |
for i in range(length): | |
os.system('git-file-size-diff {0} {1} && echo {0} {1}'.format(log_ids[i + 1], log_ids[i])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In
git-file-size-diff
, remember to comment the line where it prints the details of size difference for each file: