GeezerVison is showing github.com — Fix stale Pipfile.lock blocking sibling redirects · SocketDev/socket-patch@2ea444b
File treeExpand file treeCollapse file tree Open diff view settings Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: crates/socket-patch-core/src/crawlers/go_crawler.rs +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1196,8 +1196,7 @@ mod tests { | 1196 | 1196 | // FIRST GOPATH entry is skipped in favor of the next non-empty one | 1197 | 1197 | // (GOPATH is an OS-separator-delimited list; Go uses the first | 1198 | 1198 | // usable entry for the module cache). | 1199 | | - let gopath_list = | 1200 | | - std::env::join_paths(["".as_ref(), gopath_a.path().as_os_str()]).unwrap(); | | 1199 | + let gopath_list = std::env::join_paths(["".as_ref(), gopath_a.path().as_os_str()]).unwrap(); | 1201 | 1200 | let _gomodcache = EnvGuard::set("GOMODCACHE", ""); | 1202 | 1201 | let _gopath = EnvGuard::set("GOPATH", gopath_list.to_str().unwrap()); | 1203 | 1202 | let _home = EnvGuard::set("HOME", "/nonexistent-home-unused"); | |
Collapse file Copy file name to clipboardExpand all lines: crates/socket-patch-core/src/crawlers/nuget_crawler.rs +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -748,7 +748,9 @@ mod tests { | 748 | 748 | async fn test_scan_package_dir_dedups_same_package_across_two_scans() { | 749 | 749 | let dir = tempfile::tempdir().unwrap(); | 750 | 750 | let pkg_dir = dir.path().join("newtonsoft.json").join("13.0.3"); | 751 | | - tokio::fs::create_dir_all(pkg_dir.join("lib")).await.unwrap(); | | 751 | + tokio::fs::create_dir_all(pkg_dir.join("lib")) | | 752 | + .await | | 753 | + .unwrap(); | 752 | 754 |
| 753 | 755 | let crawler = NuGetCrawler::new(); | 754 | 756 | let mut seen = HashSet::new(); | |
Collapse file Copy file name to clipboardExpand all lines: crates/socket-patch-core/src/package_json/find.rs +1-4Lines changed: 1 addition & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -846,10 +846,7 @@ mod tests { | 846 | 846 | // below); if the team decides such values should degrade to | 847 | 847 | // WorkspaceType::None (npm semantics), update detect_workspaces and | 848 | 848 | // flip these assertions together. | 849 | | - for spelling in [ | 850 | | - r#"{"workspaces": "packages/*"}"#, | 851 | | - r#"{"workspaces": null}"#, | 852 | | - ] { | | 849 | + for spelling in [r#"{"workspaces": "packages/*"}"#, r#"{"workspaces": null}"#] { | 853 | 850 | let dir = tempfile::tempdir().unwrap(); | 854 | 851 | let pkg = dir.path().join("package.json"); | 855 | 852 | fs::write(&pkg, spelling).await.unwrap(); | |
Collapse file Copy file name to clipboardExpand all lines: crates/socket-patch-core/src/package_json/update.rs +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -787,7 +787,9 @@ mod tests { | 787 | 787 | ); | 788 | 788 | assert!(result.new_script.is_none()); | 789 | 789 | assert!( | 790 | | - result.old_dependencies_script.contains("socket-patch apply"), | | 790 | + result | | 791 | + .old_dependencies_script | | 792 | + .contains("socket-patch apply"), | 791 | 793 | "old_dependencies_script must reflect the configured script, got {:?}", | 792 | 794 | result.old_dependencies_script | 793 | 795 | ); | |
Collapse file Copy file name to clipboardExpand all lines: crates/socket-patch-core/src/patch/apply.rs +22-7Lines changed: 22 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2763,7 +2763,9 @@ mod tests { | 2763 | 2763 | assert!(result.success, "expected success: {:?}", result.error); | 2764 | 2764 | assert_eq!(result.files_patched, vec!["new.js".to_string()]); | 2765 | 2765 | assert_eq!(result.applied_via.get("new.js"), Some(&AppliedVia::Blob)); | 2766 | | - let written = tokio::fs::read(pkg_dir.path().join("new.js")).await.unwrap(); | | 2766 | + let written = tokio::fs::read(pkg_dir.path().join("new.js")) | | 2767 | + .await | | 2768 | + .unwrap(); | 2767 | 2769 | assert_eq!(written, fresh, "divergent existing content is overwritten"); | 2768 | 2770 | } | 2769 | 2771 |
| @@ -2811,7 +2813,9 @@ mod tests { | 2811 | 2813 |
| 2812 | 2814 | assert!(result.success, "strict still overwrites at a new-file path"); | 2813 | 2815 | assert_eq!(result.files_patched, vec!["new.js".to_string()]); | 2814 | | - let written = tokio::fs::read(pkg_dir.path().join("new.js")).await.unwrap(); | | 2816 | + let written = tokio::fs::read(pkg_dir.path().join("new.js")) | | 2817 | + .await | | 2818 | + .unwrap(); | 2815 | 2819 | assert_eq!(written, fresh); | 2816 | 2820 | } | 2817 | 2821 |
| @@ -2961,7 +2965,9 @@ mod tests { | 2961 | 2965 | let evil = b"pwned"; | 2962 | 2966 | let evil_hash = compute_git_sha256_from_bytes(evil); | 2963 | 2967 |
| 2964 | | - tokio::fs::write(pkg.join("index.js"), original).await.unwrap(); | | 2968 | + tokio::fs::write(pkg.join("index.js"), original) | | 2969 | + .await | | 2970 | + .unwrap(); | 2965 | 2971 | tokio::fs::write(blobs_dir.path().join(&after_hash), patched) | 2966 | 2972 | .await | 2967 | 2973 | .unwrap(); | @@ -3005,7 +3011,10 @@ mod tests { | 3005 | 3011 | assert!(result.files_patched.is_empty()); | 3006 | 3012 | // The safe file was never written — the whole apply aborted | 3007 | 3013 | // before the write phase. | 3008 | | - assert_eq!(tokio::fs::read(pkg.join("index.js")).await.unwrap(), original); | | 3014 | + assert_eq!( | | 3015 | + tokio::fs::read(pkg.join("index.js")).await.unwrap(), | | 3016 | + original | | 3017 | + ); | 3009 | 3018 | assert!(!root.path().join("escape.js").exists()); | 3010 | 3019 | } | 3011 | 3020 |
| @@ -3028,9 +3037,15 @@ mod tests { | 3028 | 3037 | after_hash: compute_git_sha256_from_bytes(b"x"), | 3029 | 3038 | }; | 3030 | 3039 |
| 3031 | | - let applied = | 3032 | | - try_apply_from_diff(Some(&entries), "new.js", dir.path(), "new.js", &info, Some("anything")) | 3033 | | - .await; | | 3040 | + let applied = try_apply_from_diff( | | 3041 | + Some(&entries), | | 3042 | + "new.js", | | 3043 | + dir.path(), | | 3044 | + "new.js", | | 3045 | + &info, | | 3046 | + Some("anything"), | | 3047 | + ) | | 3048 | + .await; | 3034 | 3049 | assert!(!applied, "new-file entries must never apply via diff"); | 3035 | 3050 | assert!(!dir.path().join("new.js").exists(), "nothing written"); | 3036 | 3051 | } | |
Collapse file Copy file name to clipboardExpand all lines: crates/socket-patch-core/src/patch/apply_lock.rs +6-6Lines changed: 6 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -496,9 +496,9 @@ mod tests { | 496 | 496 | fs2::lock_contended_error().raw_os_error() | 497 | 497 | ); | 498 | 498 | } | 499 | | - LockError::Held => panic!( | 500 | | - "a genuine flock fault must not be mislabelled as contention" | 501 | | - ), | | 499 | + LockError::Held => { | | 500 | + panic!("a genuine flock fault must not be mislabelled as contention") | | 501 | + } | 502 | 502 | } | 503 | 503 | // The fault arm returns without ever entering the retry/backoff | 504 | 504 | // path: nowhere near the 5 s budget (the old funnel-everything- | @@ -530,9 +530,9 @@ mod tests { | 530 | 530 | fs2::lock_contended_error().raw_os_error() | 531 | 531 | ); | 532 | 532 | } | 533 | | - LockError::Held => panic!( | 534 | | - "try-once mode must not mislabel a genuine flock fault as Held" | 535 | | - ), | | 533 | + LockError::Held => { | | 534 | + panic!("try-once mode must not mislabel a genuine flock fault as Held") | | 535 | + } | 536 | 536 | } | 537 | 537 | } | 538 | 538 |
| |
Collapse file Copy file name to clipboardExpand all lines: crates/socket-patch-core/src/patch/redirect/golang_local.rs +4-1Lines changed: 4 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -2177,7 +2177,10 @@ mod tests { | 2177 | 2177 |
| 2178 | 2178 | // Parity: the real run removes exactly what the dry run reported. | 2179 | 2179 | let removed_wet = reconcile_go_redirects(root, &HashSet::new(), false).await; | 2180 | | - assert_eq!(removed_wet, removed, "dry-run report must match the real run"); | | 2180 | + assert_eq!( | | 2181 | + removed_wet, removed, | | 2182 | + "dry-run report must match the real run" | | 2183 | + ); | 2181 | 2184 | assert!(!copy_dir.exists(), "real run prunes the copy"); | 2182 | 2185 | assert!(read_replace_entries(root).await.is_empty()); | 2183 | 2186 | } | |
Collapse file Copy file name to clipboardExpand all lines: crates/socket-patch-core/src/patch/redirect/pipenv.rs +6-1Lines changed: 6 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -178,7 +178,12 @@ pub(super) fn rewrite( | 178 | 178 | result.edits.extend(edits); | 179 | 179 | } | 180 | 180 | Err(detail) => { | 181 | | - result.refused_pipenv_uuids.insert(dep.patch_uuid.clone()); | | 181 | + let is_conflict = detail.contains("already exists") | | 182 | + || detail.contains("does not match") | | 183 | + || detail.contains("is not a registry package"); | | 184 | + if is_conflict { | | 185 | + result.refused_pipenv_uuids.insert(dep.patch_uuid.clone()); | | 186 | + } | 182 | 187 | result.warnings.push(RewriteWarning { | 183 | 188 | code: "redirect_pipenv_refused".into(), | 184 | 189 | detail, | |
Collapse file Copy file name to clipboardExpand all lines: crates/socket-patch-core/src/patch/redirect/replay.rs +33-14Lines changed: 33 additions & 14 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -656,9 +656,7 @@ pub async fn revert_remaining_redirect_edits( | 656 | 656 | } | 657 | 657 | } | 658 | 658 | } | 659 | | - outcome | 660 | | - .reverted_files | 661 | | - .extend(staged.keys().cloned()); | | 659 | + outcome.reverted_files.extend(staged.keys().cloned()); | 662 | 660 | pending_warnings.extend(group_warnings); | 663 | 661 | drop_indices.extend(group_drops); | 664 | 662 | } | @@ -725,9 +723,9 @@ mod tests { | 725 | 723 | let mut state = RedirectState::new(); | 726 | 724 | state.edits = edits; | 727 | 725 | for p in record_purls { | 728 | | - state | 729 | | - .records | 730 | | - .insert((*p).to_string(), crate::manifest::schema::PatchRecord { | | 726 | + state.records.insert( | | 727 | + (*p).to_string(), | | 728 | + crate::manifest::schema::PatchRecord { | 731 | 729 | uuid: "u".into(), | 732 | 730 | exported_at: "now".into(), | 733 | 731 | files: Default::default(), | @@ -776,7 +774,10 @@ mod tests { | 776 | 774 | ); | 777 | 775 | let out = revert_remaining_redirect_edits(dir.path(), &mut state, false).await; | 778 | 776 | assert!(out.fully_reverted(), "{:?}", out.refusals); | 779 | | - assert_eq!(read(dir.path(), "requirements.txt").await, "left-pad==1.3.0\n"); | | 777 | + assert_eq!( | | 778 | + read(dir.path(), "requirements.txt").await, | | 779 | + "left-pad==1.3.0\n" | | 780 | + ); | 780 | 781 | assert!(state.edits.is_empty()); | 781 | 782 | assert!(state.records.is_empty()); | 782 | 783 | | @@ -804,7 +805,10 @@ mod tests { | 804 | 805 | ); | 805 | 806 | let out = revert_remaining_redirect_edits(dir.path(), &mut state, false).await; | 806 | 807 | assert!(out.fully_reverted(), "{:?}", out.refusals); | 807 | | - assert_eq!(read(dir.path(), "pom.xml").await, "<version>2.17.1</version>\n"); | | 808 | + assert_eq!( | | 809 | + read(dir.path(), "pom.xml").await, | | 810 | + "<version>2.17.1</version>\n" | | 811 | + ); | 808 | 812 | } | 809 | 813 |
| 810 | 814 | #[tokio::test] | @@ -1248,7 +1252,9 @@ mod tests { | 1248 | 1252 | // The npm group refused; the bun group replayed. | 1249 | 1253 | assert_eq!(out.refusals.len(), 1); | 1250 | 1254 | assert_eq!(out.refusals[0].group, "npm"); | 1251 | | - assert!(read(dir.path(), "bun.lock").await.contains("upstream.example")); | | 1255 | + assert!(read(dir.path(), "bun.lock") | | 1256 | + .await | | 1257 | + .contains("upstream.example")); | 1252 | 1258 | // npm-family records are held while ANY npm-family group refused. | 1253 | 1259 | assert!(state.records.contains_key("pkg:npm/a@1")); | 1254 | 1260 | assert_eq!(state.edits.len(), 1, "only the refused npm edit remains"); | @@ -1428,7 +1434,9 @@ mod tests { | 1428 | 1434 | | 1429 | 1435 | assert!(out.reverted_files.contains("requirements.txt")); | 1430 | 1436 | // Disk and ledger untouched. | 1431 | | - assert!(read(dir.path(), "requirements.txt").await.contains("patch.example")); | | 1437 | + assert!(read(dir.path(), "requirements.txt") | | 1438 | + .await | | 1439 | + .contains("patch.example")); | 1432 | 1440 | assert_eq!(state.edits.len(), 1); | 1433 | 1441 | assert_eq!(state.records.len(), 1); | 1434 | 1442 | } | @@ -1645,7 +1653,9 @@ mod tests { | 1645 | 1653 | ); | 1646 | 1654 | let out = revert_remaining_redirect_edits(dir.path(), &mut state, false).await; | 1647 | 1655 | assert_eq!(out.refusals.len(), 1, "{out:?}"); | 1648 | | - assert!(out.refusals[0].reason.contains("missing its recorded lines")); | | 1656 | + assert!(out.refusals[0] | | 1657 | + .reason | | 1658 | + .contains("missing its recorded lines")); | 1649 | 1659 | assert_eq!(state.edits.len(), 1); | 1650 | 1660 | assert_eq!(read(dir.path(), "go.sum").await, "x v1 h1:a\n"); | 1651 | 1661 | } | @@ -1690,10 +1700,16 @@ mod tests { | 1690 | 1700 | ]; | 1691 | 1701 | for (path, kind, action, original, new) in cases { | 1692 | 1702 | let dir = TempDir::new().unwrap(); | 1693 | | - tokio::fs::create_dir_all(dir.path().join(path)).await.unwrap(); | | 1703 | + tokio::fs::create_dir_all(dir.path().join(path)) | | 1704 | + .await | | 1705 | + .unwrap(); | 1694 | 1706 | let mut state = state_with(vec![edit(path, kind, action, original, new)], &[]); | 1695 | 1707 | let out = revert_remaining_redirect_edits(dir.path(), &mut state, false).await; | 1696 | | - assert_eq!(out.refusals.len(), 1, "{kind}/{action} must refuse: {out:?}"); | | 1708 | + assert_eq!( | | 1709 | + out.refusals.len(), | | 1710 | + 1, | | 1711 | + "{kind}/{action} must refuse: {out:?}" | | 1712 | + ); | 1697 | 1713 | assert!( | 1698 | 1714 | out.refusals[0].reason.starts_with(&format!("read {path}:")), | 1699 | 1715 | "{kind}/{action}: {}", | @@ -1958,7 +1974,10 @@ mod tests { | 1958 | 1974 | ); | 1959 | 1975 | let out = revert_remaining_redirect_edits(dir.path(), &mut state, false).await; | 1960 | 1976 | assert_eq!(out.refusals.len(), 1, "{out:?}"); | 1961 | | - assert_eq!(out.refusals[0].reason, "composer.lock is not a regular file"); | | 1977 | + assert_eq!( | | 1978 | + out.refusals[0].reason, | | 1979 | + "composer.lock is not a regular file" | | 1980 | + ); | 1962 | 1981 | assert_eq!( | 1963 | 1982 | read(dir.path(), "real.lock").await, | 1964 | 1983 | "https://patch.example/a\n", | |
Collapse file Copy file name to clipboardExpand all lines: crates/socket-patch-core/src/patch/redirect/takeover.rs +27-12Lines changed: 27 additions & 12 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1082,7 +1082,10 @@ mod tests { | 1082 | 1082 | // previews — the whole-ledger replay running after per-purl | 1083 | 1083 | // reverts — must see the post-claim state); the caller owns the | 1084 | 1084 | // clone and never persists it on a dry run. | 1085 | | - assert!(state.records.len() < records_before, "record claimed in memory"); | | 1085 | + assert!( | | 1086 | + state.records.len() < records_before, | | 1087 | + "record claimed in memory" | | 1088 | + ); | 1086 | 1089 | assert!(state.edits.len() < edits_before, "edits claimed in memory"); | 1087 | 1090 |
| 1088 | 1091 | // The preview names exactly the files a wet run then reverts — | @@ -1901,7 +1904,9 @@ mod tests { | 1901 | 1904 | .and_then(Value::as_object_mut) | 1902 | 1905 | .unwrap(); | 1903 | 1906 | entry.remove("name").expect("fixture name field present"); | 1904 | | - entry.remove("version").expect("fixture version field present"); | | 1907 | + entry | | 1908 | + .remove("version") | | 1909 | + .expect("fixture version field present"); | 1905 | 1910 | tokio::fs::write( | 1906 | 1911 | root.join("package-lock.json"), | 1907 | 1912 | serde_json::to_string_pretty(&on_disk).unwrap(), | @@ -2038,9 +2043,7 @@ mod tests { | 2038 | 2043 | .await; | 2039 | 2044 | let root = tmp.path(); | 2040 | 2045 | assert_eq!(state.edits.len(), 2, "{:?}", state.edits); | 2041 | | - let scoped_url = npm_dep_for("@scope/left-pad", "1.3.0") | 2042 | | - .artifact_url | 2043 | | - .clone(); | | 2046 | + let scoped_url = npm_dep_for("@scope/left-pad", "1.3.0").artifact_url.clone(); | 2044 | 2047 | // Hand edit / merge artifact: strip the alias entry's name+version. | 2045 | 2048 | let mut on_disk: Value = serde_json::from_str( | 2046 | 2049 | &tokio::fs::read_to_string(root.join("package-lock.json")) | @@ -2054,7 +2057,9 @@ mod tests { | 2054 | 2057 | .and_then(Value::as_object_mut) | 2055 | 2058 | .unwrap(); | 2056 | 2059 | entry.remove("name").expect("fixture name field present"); | 2057 | | - entry.remove("version").expect("fixture version field present"); | | 2060 | + entry | | 2061 | + .remove("version") | | 2062 | + .expect("fixture version field present"); | 2058 | 2063 | tokio::fs::write( | 2059 | 2064 | root.join("package-lock.json"), | 2060 | 2065 | serde_json::to_string_pretty(&on_disk).unwrap(), | @@ -2361,7 +2366,9 @@ mod tests { | 2361 | 2366 | let cfg_before = tokio::fs::read_to_string(root.join(".cargo/config.toml")) | 2362 | 2367 | .await | 2363 | 2368 | .unwrap(); | 2364 | | - tokio::fs::remove_file(root.join("Cargo.lock")).await.unwrap(); | | 2369 | + tokio::fs::remove_file(root.join("Cargo.lock")) | | 2370 | + .await | | 2371 | + .unwrap(); | 2365 | 2372 | let records_before = state.records.len(); | 2366 | 2373 | let edits_before = state.edits.len(); | 2367 | 2374 |
| @@ -2515,9 +2522,12 @@ mod tests { | 2515 | 2522 | let wired_toml = tokio::fs::read_to_string(root.join("Cargo.toml")) | 2516 | 2523 | .await | 2517 | 2524 | .unwrap(); | 2518 | | - tokio::fs::write(root.join("Cargo.toml"), format!("{wired_toml}{pinned_line}")) | 2519 | | - .await | 2520 | | - .unwrap(); | | 2525 | + tokio::fs::write( | | 2526 | + root.join("Cargo.toml"), | | 2527 | + format!("{wired_toml}{pinned_line}"), | | 2528 | + ) | | 2529 | + .await | | 2530 | + .unwrap(); | 2521 | 2531 |
| 2522 | 2532 | let out = revert_cargo_redirect_purl(root, &mut state, PURL, false) | 2523 | 2533 | .await | @@ -2627,7 +2637,9 @@ mod tests { | 2627 | 2637 | async fn npm_missing_text_lock_refuses_and_keeps_the_ledger() { | 2628 | 2638 | let (tmp, mut state) = npm_redirected_fixture("yarn.lock", &classic_pristine()).await; | 2629 | 2639 | let root = tmp.path(); | 2630 | | - tokio::fs::remove_file(root.join("yarn.lock")).await.unwrap(); | | 2640 | + tokio::fs::remove_file(root.join("yarn.lock")) | | 2641 | + .await | | 2642 | + .unwrap(); | 2631 | 2643 | let records_before = state.records.len(); | 2632 | 2644 | let edits_before = state.edits.len(); | 2633 | 2645 |
| @@ -2821,7 +2833,10 @@ mod tests { | 2821 | 2833 | let err = revert_npm_redirect_purl(root, &mut state, NPM_PURL, false) | 2822 | 2834 | .await | 2823 | 2835 | .expect_err("vanished v2 tree must refuse"); | 2824 | | - assert!(err.contains("no longer holds a `dependencies` tree"), "{err}"); | | 2836 | + assert!( | | 2837 | + err.contains("no longer holds a `dependencies` tree"), | | 2838 | + "{err}" | | 2839 | + ); | 2825 | 2840 | let after = tokio::fs::read_to_string(root.join("package-lock.json")) | 2826 | 2841 | .await | 2827 | 2842 | .unwrap(); | |
|