Created
January 22, 2025 16:32
-
-
Save danwakefield/b8f61c9942c437feccfd9b6267fc77a6 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 | |
set -e | |
files=$(git diff --staged --name-only --diff-filter=ACMRTUXB | grep '\.rb$' | tr '\\\n' ' ') | |
# Check we have files before trying to run the tests. | |
# Prevents getting stuck if we only update non .rb files. | |
if [[ -n $files ]];then | |
if [ $commands[gxargs] ]; then | |
git diff --staged --name-only --diff-filter=ACMRTUXB | grep '\.rb$' | tr '\\\n' ' ' | gxargs --no-run-if-empty bundle exec rubocop -A --force-exclusion --config "$(git rev-parse --show-toplevel)/.rubocop.yml" | |
else | |
git diff --staged --name-only --diff-filter=ACMRTUXB | grep '\.rb$' | tr '\\\n' ' ' | /usr/bin/xargs bundle exec rubocop -A --force-exclusion --config "$(git rev-parse --show-toplevel)/.rubocop.yml" | |
fi | |
fi |
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 | |
protected_branch='master' | |
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') | |
if [ $protected_branch = $current_branch ] | |
then | |
echo "${protected_branch} is a protected branch, create PR to merge" | |
exit 1 # push will not execute | |
else | |
exit 0 # push will execute | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment