Created
September 1, 2020 04:52
-
-
Save jcaxmacher/0261b2cffffb099b66c510471abd9759 to your computer and use it in GitHub Desktop.
Generate change table for specific file using git commit history
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
#!/bin/bash | |
file=$1 | |
commits=`git blame $file | cut -f1 -d' ' | sort -u` | |
count=`git blame $file | cut -f1 -d' ' | sort -u | wc -l` | |
for commit in $commits; do | |
newcommit=`echo $commit | sed -e 's/^\^//g'` | |
user=`git show -s --format='%an' $newcommit` | |
dt=`git show -s --format=%ci $newcommit` | |
message=`git log --format=%B -n 1 $newcommit` | |
lines=`git blame $file | grep "^$commit" | grep -o '[^\(]*$' | cut -d')' -f1 | grep -o '[^ ]*$'` | |
newlines="" | |
for line in $lines; do | |
newlines="$newlines,$((line + count + 1))" | |
done | |
echo $dt - $user - $message - lines:$newlines | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment