-
-
Notifications
You must be signed in to change notification settings - Fork 73
fix error with empty index by including raw information in diff #229
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
Merged
+140
−6
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello there @Patrick-Beuks @lyrixx,
I'm just wondering:
Would this actually have to result in a deprecation warning?
For other tools using the DiffParser (like grumphp), we don't really care much about the raw index data.
See phpro/grumphp#1199
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are edge cases for parsing the diff that would result in an incorrect parse, not finding changed files, see issue #227.
I will check the use case as you described in your ticket to see if you would have hit the same edge cases tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oke, I have checked out your code.
You have a public interface on the diff in
src/Git/GitRepository.phpthat returns the Gitonomy diff back.Without the
--rawthis contains incorrect data and to protect consumers of this function from false information, I still think this deprecation is needed.For example this this code for the
spec/Git/GitRepositorySpec.phpAs you can see here without raw or changes the object is in an undesirable state.
(BTW thank you for letting me take another look at this, as I have found a bug with multiple files as
fileIndexnever increases)Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into it.
Sorry for my questions here, I'm just trying to understand :)
I'm trying to understand what is problematic about this, but can't really seem to find out why this should have negative impact on our application:
We don't use the new / old index anywhere. We only try to find the files from the git diff.
The way I see it:
An implementation could for example check if the indexes are set from the diff to check it is a file mode change or a difference in file content as well, without parsing the raw headers.
GrumPHP uses a diff as STDIN for the run command, so we don't always have control about the exact command the diff is created with. (we do have some presets of git hooks in which we have control, but users have the ability to overwrite those.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without raw
Diffcontains most of the times the index information. This library even expects index information always to be available on the Diff object.If you do not use the index information I would suggest to suppress the deprecation warning and wrap the Diff object in your own object and remove the index information to make is clear to users of your library that it is not accessible.
On the otherhand, if users can write their own diff, then it might be an idea to let the deprecation stand so that they can add the raw flag
Sidenote: this function does more then just get changed files, if you just need that there might even be faster option as this does parse the entire diff
(BTW I am just defending my justification for the deprecation as an end user of the library, in the end it is up to @lyrixx if this is a valid use case)