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

Fixed range parsing #115

Merged
merged 2 commits into from
Mar 23, 2023
Merged

Conversation

dg
Copy link
Contributor

@dg dg commented Mar 22, 2023

Fixes two errors when parsing diff files

  1. the range can be zero, for example if lines are only deleted or added
  2. isset($match['startrange']) is always true

@SpacePossum
Copy link
Contributor

Hi!

These changes look valid to me, nice catch 👍 : )

Sadly the CI doesn't run anymore, which seems not related to your changes.

@dg
Copy link
Contributor Author

dg commented Mar 22, 2023

I honestly have no idea why it passes in master (https://github.com/dg/sebastianbergmann-diff/actions/runs/4495014297), but it doesn't pass in any other branch (https://github.com/dg/sebastianbergmann-diff/actions/runs/4491522850)

@sebastianbergmann
Copy link
Owner

I honestly have no idea why it passes in master (https://github.com/dg/sebastianbergmann-diff/actions/runs/4495014297), but it doesn't pass in any other branch (https://github.com/dg/sebastianbergmann-diff/actions/runs/4491522850)

Should work now after 9f7efbc.

@sebastianbergmann sebastianbergmann added the bug Indicates an unexpected problem or unintended behavior label Mar 23, 2023
@sebastianbergmann sebastianbergmann merged commit 40ebaec into sebastianbergmann:main Mar 23, 2023
@sebastianbergmann
Copy link
Owner

Thank you!

@dg dg deleted the pull-fixes branch March 23, 2023 11:28
@SpacePossum
Copy link
Contributor

thansk @dg 👍 :)

@dg
Copy link
Contributor Author

dg commented Mar 23, 2023

One more thing. It's not a bug in the parser. It's just a weird meaning of the numbers 🤯 I haven't found any expanation, just a mention here https://www.artima.com/weblogs/viewpost.jsp?thread=164293

The first number is the start line of the chunk in the old or new file. The second number is chunk size in that file; it and the comma are omitted if the chunk size is 1. (Email from a reader suggests that this omission is optional and may be phased out.) If the chunk size is 0, the first number is one lower than one would expect (it is the line number after which the chunk should be inserted or deleted; in all other cases it gives the first line number or the replaced range of lines).

If you want, I'll post a PR to readme.

@sebastianbergmann
Copy link
Owner

If you want, I'll post a PR to readme.

That would be appreciated, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants