#!/usr/bin/env bash
# Before pushing a change, run this script to make sure vendor has been
# generated and that the test and lint is passing green.
#
# Install: 
# from the topdir add this file to your `.git/hooks/pre-push`  and `chmod +x .git/hooke/pre-push`

# exit 0 if NOTESTS is set
[[ -n ${NOTESTS} ]] && exit 0

# regenerate vendor, in case you add a lib that is not in vendor dir
make vendor

# if there was some new vendor files that wasn't generated it would bug out here
git status -uno vendor/|grep -q "nothing to commit" || {
    echo "Vendor directory has not been regenerated properly, commit the change first"
    git status -uno
    exit 1
}


make test lint 
exit $?

