Ruby example use staged for git diff #56
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
git diff --name-only HEAD master
doesn't show the current files thatare staged for changes, only the previously committed changes
I think using
--staged
is a better example for the docs, because it willrun the command against the files you are committing. I think it better
represents what people expect to happen (the files I'm trying to commit will
have rubocop run against them)
I can throw an example git repo up w/ some examples of why I think this
is a better option to present as a default if that helps, but here's a screenshot:
test.rb
file to the branchfoo_spec.rb
staged, and I'm adding it as a commit to the branchUsing
HEAD master
I only see thetest.rb
file in the output; so lefthook actually skips running rubocop onfoo_spec.rb
(which has a violation).I expected lefthook to fail on the rubocop violation (file is staged, I'm committing it) but it did not, because it only looked at my previous committed file (
test.rb
)