Running Rubocop before push
Setup the pre-push hook to run rubocop before push
May 1, 2018
-
2 minute read
-
Tired of create commits like “Fix rubocop violations” after push your code?
How about run rubocop before each git push
operation?
Setup the pre-push hook
Create the file below and save it as pre-push
in your project’s hook directory:
your-project/.git/hooks/
Then make it executable:
From now on Rubocop will run before git push
operation.
Testing the hook
Make sure you have rubocop installed before proceed.
The push action will be cancelled once a violation is detected, as shown in the example below:
After fix the violations you will be able to push the code without problems.
Sources