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

git's noprefix option breaks diff-cover #93

Closed
beaugunderson opened this issue Mar 14, 2019 · 3 comments
Closed

git's noprefix option breaks diff-cover #93

beaugunderson opened this issue Mar 14, 2019 · 3 comments

Comments

@beaugunderson
Copy link
Contributor

I have this in my .gitconfig:

[diff]
	noprefix = true

This breaks diff-cover's regex, which expects there to be a/ and b/ prefixes in the diff output.

It's easy enough to disable the option, but I'd love to find a way to have the option for my normal use and have diff-cover still work. :)

@beaugunderson
Copy link
Contributor Author

This is the stack, fwiw:

Traceback (most recent call last):
  File "/Users/beau/.envs/home/bin/diff-cover", line 10, in <module>
    sys.exit(main())
  File "/Users/beau/.envs/home/lib/python3.7/site-packages/diff_cover/tool.py", line 350, in main
    src_roots=arg_dict['src_roots'],
  File "/Users/beau/.envs/home/lib/python3.7/site-packages/diff_cover/tool.py", line 279, in generate_coverage_report
    reporter.generate_report(output_file)
  File "/Users/beau/.envs/home/lib/python3.7/site-packages/diff_cover/report_generator.py", line 215, in generate_report
    report = template.render(self._context())
  File "/Users/beau/.envs/home/lib/python3.7/site-packages/diff_cover/report_generator.py", line 259, in _context
    src: self._src_path_stats(src) for src in self.src_paths()
  File "/Users/beau/.envs/home/lib/python3.7/site-packages/diff_cover/report_generator.py", line 83, in src_paths
    return {src for src, summary in self._diff_violations().items()
  File "/Users/beau/.envs/home/lib/python3.7/site-packages/diff_cover/report_generator.py", line 175, in _diff_violations
    for src_path in self._diff.src_paths_changed()
  File "/Users/beau/.envs/home/lib/python3.7/site-packages/diff_cover/diff_reporter.py", line 147, in src_paths_changed
    diff_dict = self._git_diff()
  File "/Users/beau/.envs/home/lib/python3.7/site-packages/diff_cover/diff_reporter.py", line 198, in _git_diff
    diff_dict = self._parse_diff_str(diff_str)
  File "/Users/beau/.envs/home/lib/python3.7/site-packages/diff_cover/diff_reporter.py", line 248, in _parse_diff_str
    sections_dict = self._parse_source_sections(diff_str)
  File "/Users/beau/.envs/home/lib/python3.7/site-packages/diff_cover/diff_reporter.py", line 286, in _parse_source_sections
    src_path = self._parse_source_line(line)
  File "/Users/beau/.envs/home/lib/python3.7/site-packages/diff_cover/diff_reporter.py", line 410, in _parse_source_line
    raise GitDiffError(msg)
diff_cover.git_diff.GitDiffError: Could not parse source path in line 'diff --git home-app/.coveragerc home-app/.coveragerc'

@beaugunderson
Copy link
Contributor Author

Looks like there's precedent to setting git options in GitDiffTool already:

        return execute([
            'git', '-c', 'diff.mnemonicprefix=no', 'diff',
            "{branch}...HEAD".format(branch=compare_branch),
            '--no-color',
            '--no-ext-diff'
        ])[0]

Disabling noprefix here fixed my problem:

        return execute([
            'git', '-c', 'diff.mnemonicprefix=no', '-c',
            'diff.noprefix=no', 'diff',
            "{branch}...HEAD".format(branch=compare_branch),
            '--no-color',
            '--no-ext-diff'
        ])[0]

@beaugunderson
Copy link
Contributor Author

(will have a PR for this today, likely)

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

1 participant