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

Ruby example use staged for git diff #56

Merged
merged 1 commit into from
Aug 7, 2019
Merged

Ruby example use staged for git diff #56

merged 1 commit into from
Aug 7, 2019

Conversation

jaydorsey
Copy link
Contributor

git diff --name-only HEAD master doesn't show the current files that
are staged for changes, only the previously committed changes

I think using --staged is a better example for the docs, because it will
run 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:

image

  • I'm on a branch (off of master)
  • I had 1 commit where I added test.rb file to the branch
  • I have foo_spec.rb staged, and I'm adding it as a commit to the branch

Using HEAD master I only see the test.rb file in the output; so lefthook actually skips running rubocop on foo_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)

`git diff --name-only HEAD master` doesn't show the _current_ files that
are staged for changes, only the previously committed changes

I think using `--staged` is a better example for this, because it will
run the command against the files you are commiting

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.
@Arkweid
Copy link
Collaborator

Arkweid commented Aug 7, 2019

Thank you @jaydorsey you are right!

@Arkweid Arkweid merged commit 6f09870 into evilmartians:master Aug 7, 2019
@jaydorsey jaydorsey deleted the jay/ruby_rubocop_docs branch August 7, 2019 16:34
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

Successfully merging this pull request may close these issues.

2 participants