Skip to content

Instantly share code, notes, and snippets.

@jbn
Created May 11, 2017 21:06
Show Gist options
  • Save jbn/30b68a85e872fc504103940598fe8831 to your computer and use it in GitHub Desktop.
Save jbn/30b68a85e872fc504103940598fe8831 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Sketch of an idea. If you've been commiting fixes too much recently, you
# should probably stop what your doing and think a bit. In teams, someone
# else tells you to do so. But, when your by yourself, broken glass can
# accumulate, until one day -- poof.
export MAX_FAILURES=3
export LAST_N_COMMITS=10
# You can only escape with a refactor.
git log -1 --pretty=oneline --abbrev-commit | grep -i refactor > /dev/null
if [ $? -eq 0 ]; then
exit 0
fi
git log -$LAST_N_COMMITS --pretty=oneline --abbrev-commit | \
grep -i fix | wc | awk -F ' ' '{print $1}' | \
(
read N_FAILURES;
if (($N_FAILURES > $MAX_FAILURES)); then
echo "DUNCE MODE ACTIVATED ON $N_FAILURES FALURES!"
exit 1
fi
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment