rubocop-git
rubocop-git copied to clipboard
Raises error when git configuration `diff.mnemonicprefix` is enabled
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
.
@dsbonev Thanks for the idea about how to work around this issue. 👍
Just to save others a bit of time... the line https://github.com/m4i/rubocop-git/blob/8d6d002390427fe7fe8f425e5ccf8855ff62cebb/lib/rubocop/git/runner.rb#L36 needs to be changed to this:
args = %w(-c diff.mnemonicprefix=false diff --diff-filter=AMCR --find-renames --find-copies)
@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.
if anyone is still using this, i've release a forked gem, rubocop-git2
, with this and other fixes included
@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.