-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from epimorphics/spike/resolve-rubocop-warnings
Task: Release v1.5.2
- Loading branch information
Showing
11 changed files
with
283 additions
and
130 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/sh | ||
# caveat: this script assumes all modifications to a file were staged in the commit | ||
# beware if you are in the habit of committing only partial modifications to a file: | ||
# THIS HOOK WILL ADD ALL MODIFICATIONS TO A FILE TO THE COMMIT IF ANY FILE WAS CHANGED BY LINTING | ||
|
||
list="issue spike task" | ||
|
||
listRE="^($(printf '%s\n' "$list" | tr ' ' '|'))/" | ||
|
||
BRANCH_NAME=$(git branch --show-current | grep -E "$listRE" | sed 's/* //') | ||
|
||
printf '\n\033[0;105mChecking "%s"... \033[0m\n', "$BRANCH_NAME" | ||
|
||
if echo "$BRANCH_NAME" | grep -q '^(rebase)|(production)*$'; then | ||
printf '\n\033[0;32mNo checks necessary on "%s", pushing now... 🎉\033[0m\n', "$BRANCH_NAME" | ||
exit 0 | ||
fi | ||
|
||
RUBY_FILES="$(git diff --diff-filter=d --name-only --cached | grep -E '(Gemfile|Rakefile|\.(rb|rake|ru))$')" | ||
|
||
PRE_STATUS="$(git status | wc -l)" | ||
|
||
WORK_DONE=0 | ||
|
||
if [ -n "$RUBY_FILES" ]; then | ||
printf '\nRunning Rubocop...' | ||
for file in $RUBY_FILES; do | ||
git show :"$file" | bundle exec rubocop -A --stdin "$file" | ||
done | ||
RUBOCOP_EXIT_CODE=$? | ||
WORK_DONE=1 | ||
else | ||
RUBOCOP_EXIT_CODE=0 | ||
fi | ||
|
||
POST_STATUS="$(git status | wc -l)" | ||
|
||
if [ ! $RUBOCOP_EXIT_CODE -eq 0 ]; then | ||
git reset HEAD | ||
printf '\n\033[0;31mLinting has unfixable errors; please fix and restage your commit. 😖\033[0m\n' | ||
exit 1 | ||
fi | ||
|
||
if [ "$PRE_STATUS" != "$POST_STATUS" ]; then | ||
git add "$RUBY_FILES" "$ESLINT_FILES" "$PRETTIER_FILES" | ||
fi | ||
|
||
if [ $WORK_DONE -eq 1 ]; then | ||
printf '\n\033[0;32mLinting completed successfully! 🎉\033[0m\n' | ||
fi | ||
|
||
exit 0 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/sh | ||
|
||
list="issue spike task" | ||
|
||
listRE="^($(printf '%s\n' "$list" | tr ' ' '|'))/" | ||
|
||
BRANCH_NAME=$(git branch --show-current | grep -E "$listRE" | sed 's/* //') | ||
|
||
printf '\n\033[0;105mChecking "%s"... \033[0m\n', "$BRANCH_NAME" | ||
|
||
if echo "$BRANCH_NAME" | grep -q '^(rebase)|(production)*$'; then | ||
printf '\n\033[0;32mNo checks necessary on "%s", pushing now... 🎉\033[0m\n', "$BRANCH_NAME" | ||
exit 0 | ||
fi | ||
|
||
# Check for existence of "new or modified" test files | ||
TEST_FILES="$(git diff --diff-filter=ACDM --name-only --cached | grep -E '(./test/*)$')" | ||
# Get all test files to run tests | ||
RUBY_FILES="$(git ls-files | grep -i -E '(_test\.rb)$')" | ||
|
||
WORK_DONE=0 | ||
|
||
if [ -z "$TEST_FILES" ]; then | ||
printf 'There are no new tests created in "%s".\n', "$BRANCH_NAME" | ||
printf '\n\033[0;31mContinuing without new tests... 😖\033[0m\n' | ||
fi | ||
|
||
if [ -n "$RUBY_FILES" ]; then | ||
printf '\nRunning Unit Tests...' | ||
make test | ||
RUBY_TEST_EXIT_CODE=$? | ||
WORK_DONE=1 | ||
else | ||
RUBY_TEST_EXIT_CODE=0 | ||
fi | ||
|
||
if [ ! $RUBY_TEST_EXIT_CODE -eq 0 ]; then | ||
printf '\n\033[0;31mCannot push, tests are failing. Use --no-verify to force push. 😖\033[0m\n' | ||
exit 1 | ||
fi | ||
|
||
if [ $WORK_DONE = 1 ]; then | ||
printf '\n\033[0;32mAll tests are green, pushing... 🎉\033[0m\n' | ||
fi | ||
|
||
exit 0 |
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
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
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
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
Oops, something went wrong.