Skip to content

Instantly share code, notes, and snippets.

@amseddi
Created August 4, 2016 08:34
Show Gist options
  • Select an option

  • Save amseddi/e85617ceac53e559be9c380de73ee4bc to your computer and use it in GitHub Desktop.

Select an option

Save amseddi/e85617ceac53e559be9c380de73ee4bc to your computer and use it in GitHub Desktop.
#!/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
@amseddi
Copy link
Author

amseddi commented Aug 4, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment