Skip to content

Instantly share code, notes, and snippets.

@sverweij
Last active April 17, 2016 08:32
Show Gist options
  • Save sverweij/a904ba66ef3b7762924a to your computer and use it in GitHub Desktop.
Save sverweij/a904ba66ef3b7762924a to your computer and use it in GitHub Desktop.
pre-push git hook - smoke tests & when successful pushes to mirrors

pre-push hook:

set -eu
remote="$1"
url="$2"
BRANCH=`git branch | grep "^* [a-zA-Z]" | cut -c 3- `

# npm run lint && npm run jscs  && npm run test &&
if [ $remote == 'origin' ]
then
    make check
    if [ $BRANCH == 'master' ] && [ $? == 0 ]
    then
        make push-mirrors
    fi
fi

exit $?

with this make target:

GIT=git

push-mirrors:
    $(GIT) push bitbucket-mirror
    $(GIT) push gitlab-mirror
    

(and a check target that e.g. hints, tests, stylechecks)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment