Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No longer possible to use exit code after autocorrect to determine if something was wrong #1565

Closed
andreaseger opened this issue Jan 12, 2015 · 0 comments
Assignees

Comments

@andreaseger
Copy link
Contributor

This commit [https://github.com/bbatsov/rubocop/commit/15191030e9d8fad9fc93860d2bd732eb485ee2a1] will break our rubocop workflow.

So till now(upto 0.27.1) it worked like this:
Apart from everyone in the team manually running rubocop we let rubocop run in a pre-commit hook.
This hook passes all changed(and to-be-commited) files to rubocop to check and auto-correct them. After that it simply passed the exit code from rubocop to git which would abort the commit if there where any issues regardless if they could be auto-corrected.

Since 0.28.0 if all issues could be auto-corrected the exit code is now 0 which will in our case not stop the commit and even worse will commit the files before rubocop cleaned up the issues.

So currently I only see two options for our hook to handle the new behavior which both do not sound appealing:

  1. just automatically add the changes to the current commit before moving on. Meaning calling git add on the fixed file. This has at least the problem that it would break git add --patch as the hidden git add would just add the hole file.
  2. I add a bunch of code to parse the output(or the json) from rubocop to determine the exit-code which should be passed to git ( currently our hook only has to know how to call rubocop )

The IMHO nicer solution would be to make the exit-code in case of corrected issues be configurable by the --fail-level option

@jonas054 jonas054 self-assigned this Jan 17, 2015
bbatsov added a commit that referenced this issue Jan 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants