Skip to content

Instantly share code, notes, and snippets.

@gmtborges
Created July 27, 2022 14:30
Show Gist options
  • Save gmtborges/f30d4d5c2811fd030a6969a430e91d7b to your computer and use it in GitHub Desktop.
Save gmtborges/f30d4d5c2811fd030a6969a430e91d7b to your computer and use it in GitHub Desktop.
GIT pre-merge-commit sample
#!/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