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 diff lines starting with two plus characters are handled as new files #7

Open
jongiddy opened this issue Jul 1, 2015 · 0 comments

Comments

@jongiddy
Copy link

jongiddy commented Jul 1, 2015

The parsing in

if line.startswith('+++'):
# place marker - name of file
# +++ <filename>
new_file = line.split(None, 1)[1]
new_file = new_file.split('\t', 1)[0]
reads any sequence of +++ as a file boundary. Since git diff puts a + at the start of new lines, and new line that starts with ++ will get treated as file boundary.

If the line contains no spaces, this leads to an error like:

Traceback (most recent call last):
  File "/srv/buildslave/flocker-coverage/venv/bin/coverage-reporter", line 5, in <module>
    __main__.main(sys.argv)
  File "/srv/buildslave/flocker-coverage/venv/lib/python2.7/site-packages/coverage_reporter/__main__.py", line 63, in main
    data = filter_coverage(data, plugins.get_filters())
  File "/srv/buildslave/flocker-coverage/venv/lib/python2.7/site-packages/coverage_reporter/__main__.py", line 36, in filter_coverage
    data = filter.filter(data)
  File "/srv/buildslave/flocker-coverage/venv/lib/python2.7/site-packages/coverage_reporter/filters/patch.py", line 13, in filter
    return filter_by_patch(coverage_data, self.patch, self.patch_level)
  File "/srv/buildslave/flocker-coverage/venv/lib/python2.7/site-packages/coverage_reporter/filters/patch.py", line 20, in filter_by_patch
    lines = _get_lines_from_patch(patch_file, patch_level)
  File "/srv/buildslave/flocker-coverage/venv/lib/python2.7/site-packages/coverage_reporter/filters/patch.py", line 40, in _get_lines_from_patch
    new_file = line.split(None, 1)[1]
IndexError: list index out of range

I haven't observed what happens if there is a space in the line, but it should be different to this IndexError.

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