Patch fails to apply (sometimes silently) when patch includes additions to the end of a file
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 325
- PR merge metrics
- No merged PRs in 30d
Description
Hiya,
We stumbled across a bit of a weird edge case that we thought you might like to know about. After doing some digging, it appears the required steps to reproduce are:
* the file you are patching has no newline at the end of it
* you are adding another line to the end of that file (still with no newline)
I can't link the original patch we were working on, but I've reproduced it here: https://github.com/lukebatchelor/patch-package-repro
We had a brief look at trying to fix this (originally assuming patch-package was using git-apply under the hood and hoping we could just pass on the `--inaccurate-eof` [flag](https://git-scm.com/docs/git-apply#Documentation/git-apply.txt---inaccurate-eof) but alas you weren't. It does look like you have [explicit code for handling this](https://github.com/ds300/patch-package/blob/5c2c92bf504885fba4840870a23fc8999c00e572/src/patch/apply.ts#L83) so likely just a small edge case in that logic.
Hope this helps, thanks for making this package
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.