Skip to content

Commit 8805144

Browse files
committed
Treat a uv exclude-newer of false as no cutoff
uv 0.11.24+ accepts `--exclude-newer false` and `UV_EXCLUDE_NEWER=false` to turn the global cutoff off, and a pylock compiled that way keeps every file. Both were read as cutoffs and refused the restore. Treat false as no cutoff, as the per-package and settings checks already do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FW66bMcoJmYGQykhbfuA8u
1 parent f94a1b6 commit 8805144

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

‎crates/socket-patch-core/src/patch/redirect/upstream/uv.rs‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,10 @@ async fn restore_lock(
416416
for hit in &hits {
417417
let why = if let Some(flag) = compile_filter(&command, &hit.name) {
418418
format!("`uv pip compile {flag}` filters")
419-
} else if env_set("UV_EXCLUDE_NEWER") {
419+
} else if std::env::var_os("UV_EXCLUDE_NEWER")
420+
// Empty is unset, and `false` turns the cutoff off.
421+
.is_some_and(|v| !v.is_empty() && v != "false")
422+
{
420423
"the `UV_EXCLUDE_NEWER` cutoff set in this environment filters".to_string()
421424
} else if let Some((path, key)) = settings_filter(&settings, &hit.name) {
422425
format!("{path}'s uv `{key}` setting filters")
@@ -727,7 +730,9 @@ fn compile_filter(command: &[&str], name: &str) -> Option<String> {
727730
_ => (*arg, None),
728731
};
729732
let applies = match flag {
730-
"--no-build" | "--exclude-newer" => true,
733+
"--no-build" => true,
734+
// `false` turns the cutoff off (uv 0.11.24+).
735+
"--exclude-newer" => inline.or_else(|| args.next().copied()) != Some("false"),
731736
"--only-binary" | "--no-binary" | "--exclude-newer-package" => {
732737
let Some(value) = inline.or_else(|| args.next().copied()) else {
733738
continue;

‎crates/socket-patch-core/tests/upstream_restore_golden.rs‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2262,6 +2262,8 @@ async fn pip_compile_pylock_build_filters_refuse_the_filtered_entry() {
22622262
" --no-build-isolation",
22632263
" --exclude-newer-package idna=2023-01-01T00:00:00Z",
22642264
" --exclude-newer-package urllib3=false",
2265+
" --exclude-newer false",
2266+
" --exclude-newer=false",
22652267
] {
22662268
let input = tree(&[("pylock.toml", with_flags(flags))]);
22672269
assert_pypi_round_trip(flags, &input, &[urllib3_dep()], None).await;
@@ -2352,10 +2354,12 @@ async fn pip_compile_pylock_build_filters_refuse_the_filtered_entry() {
23522354
let (why, _, _) = pypi_refusal(&input, &[urllib3_dep()], &RestoreOptions::default()).await;
23532355
assert!(why.contains(expect), "{why}");
23542356
}
2355-
let _env = EnvGuard::set(&[("UV_EXCLUDE_NEWER", String::new())]);
2356-
let input = tree(&[("pylock.toml", uv_pylock(false))]);
2357-
assert_pypi_round_trip("empty UV_EXCLUDE_NEWER", &input, &[urllib3_dep()], None).await;
2358-
drop(_env);
2357+
// Empty is unset, and `false` turns the cutoff off.
2358+
for value in ["", "false"] {
2359+
let _env = EnvGuard::set(&[("UV_EXCLUDE_NEWER", value.to_string())]);
2360+
let input = tree(&[("pylock.toml", uv_pylock(false))]);
2361+
assert_pypi_round_trip("UV_EXCLUDE_NEWER off", &input, &[urllib3_dep()], None).await;
2362+
}
23592363
// With no uv command line recorded (`--no-header`, or a header that
23602364
// `UV_CUSTOM_COMPILE_COMMAND` replaced) the flags cannot be ruled out.
23612365
let comment = "# This file was autogenerated by uv via the following command:\n";

0 commit comments

Comments
 (0)