fix(patching): accept CRLF patch files (#14584)
Update `diffy` to 0.5.2 so pnpm v12 can parse patch file headers with CRLF line endings. Add a regression test that applies a CRLF-encoded patch to an LF target file. Fixes pnpm/pnpm#14557.
This commit is contained in:
1 parent
cf5a7bf514
commit
3e2aabe03d
3 files changed
+28
-2
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"pacquet": patch
|
||||
---
|
||||
|
||||
`pnpm install` now applies patch files with CRLF line endings [pnpm/pnpm#14557](https://github.com/pnpm/pnpm/issues/14557).
|
||||
Generated
+2
-2
@@ -1667,9 +1667,9 @@ checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8"
|
||||
|
||||
[[package]]
|
||||
name = "diffy"
|
||||
version = "0.5.1"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10aec8f7f9393bd6a4f2762be0ceb012d3cbe2478987258cc9960de148561914"
|
||||
checksum = "3e3dc2f773b6aaa63b1a7684b8589f670a8a0146a510b74d23a401c882364b49"
|
||||
dependencies = [
|
||||
"hashbrown 0.17.0",
|
||||
]
|
||||
|
||||
@@ -90,6 +90,27 @@ fn applies_modify_against_existing_file() {
|
||||
assert_eq!(after, IS_POSITIVE_INDEX_JS_PATCHED);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn applies_patch_with_crlf_line_endings() {
|
||||
let patched = tempdir().unwrap();
|
||||
let target = patched.path().join("file.txt");
|
||||
fs::write(&target, "one\ntwo\n").unwrap();
|
||||
let patch_dir = tempdir().unwrap();
|
||||
let hunk = text_block_fnl! {
|
||||
"@@ -1,2 +1,3 @@"
|
||||
" one"
|
||||
"+added"
|
||||
" two"
|
||||
};
|
||||
let crlf_patch = format!("{FILE_TXT_PATCH_HEADER}{hunk}").replace('\n', "\r\n");
|
||||
let patch = write_patch(patch_dir.path(), &crlf_patch);
|
||||
|
||||
apply_patch_to_dir(patched.path(), &patch).expect("apply must succeed");
|
||||
|
||||
let after = fs::read_to_string(target).unwrap();
|
||||
assert_eq!(after, "one\nadded\r\ntwo\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn applies_an_insertion_with_context_on_both_sides() {
|
||||
let original = text_block_fnl! {
|
||||
|
||||
Reference in new issue
Block a user