Created
August 4, 2016 08:34
-
-
Save amseddi/e85617ceac53e559be9c380de73ee4bc to your computer and use it in GitHub Desktop.
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
| #!/bin/bash | |
| CMD="ls -l" # Command that runs your tests | |
| protected_branch='master' | |
| # Check if we actually have commits to push | |
| commits=`git log @{u}..` | |
| if [ -z "$commits" ]; then | |
| exit 0 | |
| fi | |
| current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') | |
| if [[ $current_branch = $protected_branch ]]; then | |
| $CMD | |
| RESULT=$? | |
| if [ $RESULT -ne 0 ]; then | |
| echo "failed $CMD" | |
| exit 1 | |
| fi | |
| fi | |
| exit 0 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
inspired by http://blog.ittybittyapps.com/blog/2013/09/03/git-pre-push/