Created
July 27, 2022 14:30
-
-
Save gmtborges/f30d4d5c2811fd030a6969a430e91d7b to your computer and use it in GitHub Desktop.
GIT pre-merge-commit sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
. "$(dirname -- "$0")/_/husky.sh" | |
echo "pre merge hook" | |
DEVELOP='develop' | |
BRANCH_STAGING='staging-test' | |
if [ `git rev-parse --abbrev-ref HEAD` == $BRANCH_STAGING ]; | |
then | |
MERGE_BRANCH=`echo $GIT_REFLOG_ACTION | awk '{print $2}'` | |
if [ `git rev-list --count $MERGE_BRANCH..develop` -gt 0 ]; | |
then | |
echo "" | |
echo "###########################################" | |
echo "SUA BRANCH ESTÁ DESATUALIZADA COM A DEVELOP" | |
echo "aborte esse merge (git merge --abort)" | |
echo "" | |
echo "E ATUALIZE SUA BRANCH PRIMEIRO" | |
echo "(git checkout <sua-branch> && git rebase develop)" | |
echo "###########################################" | |
echo "" | |
echo "LEMBRE-SE TAMBÉM SE A DEVELOP ESTÁ ATUALIZADA" | |
echo "(git checkout develop && git pull)" | |
echo "" | |
exit 1 | |
else | |
exit 0 | |
fi | |
else | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment