Skip to content

Instantly share code, notes, and snippets.

@marek-saji
Created April 4, 2017 08:24
Show Gist options
  • Save marek-saji/ac77c668b2075d913231b5c674cabe8e to your computer and use it in GitHub Desktop.
Save marek-saji/ac77c668b2075d913231b5c674cabe8e to your computer and use it in GitHub Desktop.
#!/bin/sh
if [ "$2" = "template" ] || [ "$2" = "commit" ]
then
STAT="$( command git diff --cached --shortstat )"
if [ -n "${STAT}" ]
then
INS="$( echo "${STAT}" | grep -Eo '[0-9]+ insertion' | grep -o '[0-9]*' )"
DEL="$( echo "${STAT}" | grep -Eo '[0-9]+ deletion' | grep -o '[0-9]*' )"
INS="${INS:-0}"
DEL="${DEL:-0}"
if [ "${DEL}" -gt "${INS}" ]
then
printf "# (·o·),🎉 -< You are deleting more lines, than adding. >\n" \
>> "${COMMIT_MSG}"
fi
printf "# %s\n#\n" "${STAT}" >> "${COMMIT_MSG}"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment