Last active
January 3, 2016 07:29
-
-
Save n-st/8430010 to your computer and use it in GitHub Desktop.
Git post-receive hook to rebase dev branch onto master (if no changes have been made to the working copy)
This file contains 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
#!/bin/bash | |
cd .. | |
GIT_DIR='.git' | |
while read oldrev newrev ref | |
do | |
if [ "$ref" != "refs/heads/dev" ] | |
then | |
echo -e "\e[33mPushed branch isn't 'dev'. Skipping rebase dev->master.\e[0m" | |
exit 1 | |
fi | |
done | |
if ! git diff --quiet | |
then | |
echo -e "\e[31mWorking copy has been changed:\e[0m" | |
git status | |
exit 1 | |
fi | |
if git rebase dev master | |
then | |
echo -e "\e[32mSuccessfully rebased 'dev' onto 'master'.\e[0m" | |
else | |
echo -e "\e[31mRebasing 'dev' onto 'master' failed.\e[0m" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment