Skip to content

Instantly share code, notes, and snippets.

@jcaxmacher
Created September 1, 2020 04:52
Show Gist options
  • Save jcaxmacher/0261b2cffffb099b66c510471abd9759 to your computer and use it in GitHub Desktop.
Save jcaxmacher/0261b2cffffb099b66c510471abd9759 to your computer and use it in GitHub Desktop.
Generate change table for specific file using git commit history
#!/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