Files
configs/.mgr_config/bin/git-lazy-description

20 lines
428 B
Bash
Executable File

#!/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