-
Notifications
You must be signed in to change notification settings - Fork 501
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
Support multiple diff hunks #60
Comments
@piranna apply should work with multiple chunks. Can you provide an example of the input and output you are seeing? It does not support multiple files but there perhaps could be a callback-based API that would allow for something like that without too much effort. |
I did it only by eye-sign, I've just reviewed it and maybe it wronged me that at Lines 25 to 30 in 5112106
JsDiff could have a streams of objects that emit a data event for each different file in the original diffStr with the path of the file to be patched and the diffStr fragment that should be applied to that file, so later the user can call to applyPath() with the original file content and the diffStr fragment for that file. |
I'm working on separating the patch apply and parse logic. Once this is done, callers will be able to parse and then iterate over this object if they have multiple files. |
Implemented |
Really cool, thank you! :-D |
Released in 2.1.0 |
👍 :-) |
The method
applyPatch()
seems only support the first diff hunks, that don't allow to use it when a patch file has several chunks or chunks for several files. First case would be easy to do, just only continue for the next one. For the several files case it would be harder, but how could it be done, specially when you don't know the exact files that need to be patched? Maybe a hash object with the string content of the files, being the paths the key?The text was updated successfully, but these errors were encountered: