Last active
April 12, 2023 02:24
-
-
Save banyudu/0735ede0b9236751b4dea4c733fc7b91 to your computer and use it in GitHub Desktop.
Generate git commit sha for every line of code in given file
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
#!/bin/bash | |
# Check if a filename was provided as an argument | |
if [ -z "$1" ]; then | |
echo "Usage: git blame-all filename" | |
exit 1 | |
fi | |
# Loop through each line of the given file and run git blame | |
line_number=1 | |
while read line; do | |
commit_sha=$(git blame -L $line_number,$line_number "$1" | cut -c -8) | |
#echo "$line_number: $commit_sha" | |
echo "$commit_sha" : "$line" | |
line_number=$((line_number+1)) | |
done < "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment