git: add lazy checkin scripts

This commit is contained in:
2020-07-05 13:36:18 -07:00
parent f01d02ceaa
commit 909c0c336f
2 changed files with 71 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
#!/bin/bash
diffstat="$(git diff --staged --numstat | awk '{print ($1 + $2), $3}' | sort -k1nr)"
count=$(echo "$diffstat" | wc -l)
if [[ -z "$diffstat" ]]; then
echo "No staged changes to describe" >&2
exit 1
fi
file=$(echo "$diffstat" | head -n1 | cut -f2 -d' ')
if [[ $count -eq 1 ]]; then
echo "Update $file"
elif [[ $count -gt 1 ]]; then
echo "Update \`$file\` and $((count - 1)) other files"
fi
exit 0