Skip to content

Instantly share code, notes, and snippets.

@Gazzell
Gazzell / pre-push
Created January 31, 2018 09:12
pre-push git hook, only pushes if there's a versioning message in at least one of the commits ('feat:', 'fix:', 'chore:'....)
#!/bin/sh
# An example hook script to verify what is about to be pushed.  Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed.  If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
@Gazzell
Gazzell / pre-commit
Created January 31, 2018 09:09
pre-commit. Only commit if pass tests and there are not leftovers (.only and .skip)
branch=`git symbolic-ref HEAD`
if [ "$branch" = "refs/heads/master" ]; then
echo "Direct commits to the branch master are not allowed"
exit 1
fi
testLeftOvers=`git diff --staged test/**/* | grep '^+' | grep '.only\|.skip'`
if [ -n "$testLeftOvers" ]; then