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

Raises error when git configuration diff.mnemonicprefix is enabled #20

Open
dsbonev opened this issue Jun 29, 2016 · 4 comments
Open

Raises error when git configuration diff.mnemonicprefix is enabled #20

dsbonev opened this issue Jun 29, 2016 · 4 comments

Comments

@dsbonev
Copy link

dsbonev commented Jun 29, 2016

Output is

.gem/ruby/2.1.2/gems/rubocop-git-0.1.1/lib/rubocop/git/diff_parser.rb:24:in `block in parse': undefined method `patch' for nil:NilClass (NoMethodError)

The following regex does not match the patched file name

[1] pry(main)> '+++ i/test.rb' =~ %r{^\+{3} b/(?<path>[^\t\n\r]+)} 
=> nil

It has i/ prefix instead of b/ because I have diff.mnemonicprefix enabled.

To fix this I would suggest either (1) handle the mnemonic prefixes as well or (2) pass configuration option when this gem executes the git diff command git -c diff.mnemonicprefix=false.

@gerrywastaken
Copy link

gerrywastaken commented Jul 28, 2016

@dsbonev Thanks for the idea about how to work around this issue. 👍

Just to save others a bit of time... the line

args = %w(diff --diff-filter=AMCR --find-renames --find-copies)
needs to be changed to this:
args = %w(-c diff.mnemonicprefix=false diff --diff-filter=AMCR --find-renames --find-copies)

@collin-mcgrath
Copy link

@m4i Looks like #32 provides a solution for this and the --no-color issue. Can we get it merged in? This would have saved me a world of hurt getting the gem to work.

@jaynetics
Copy link

if anyone is still using this, i've release a forked gem, rubocop-git2, with this and other fixes included

@gerrywastaken
Copy link

@jaynetics Why not link it: jaynetics/rubocop-git2. Also, updating the readme with usage info and screenshots would probably lead to this getting a lot more use.

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

4 participants