mirror of https://github.com/astral-sh/uv
Strip `--index` and `--default-index` from command header (#9288)
## Summary The new `--index` and `--default-index` flags are being omitted in the `uv pip compile` header, unintentionally. Closes https://github.com/astral-sh/uv/issues/9287.
This commit is contained in:
parent
b19ccb6b97
commit
829eed8e35
|
|
@ -582,14 +582,24 @@ fn cmd(
|
|||
|
||||
// Skip any index URLs, unless requested.
|
||||
if !include_index_url {
|
||||
if arg.starts_with("--extra-index-url=") || arg.starts_with("--index-url=") {
|
||||
if arg.starts_with("--extra-index-url=")
|
||||
|| arg.starts_with("--index-url=")
|
||||
|| arg.starts_with("-i=")
|
||||
|| arg.starts_with("--index=")
|
||||
|| arg.starts_with("--default-index=")
|
||||
{
|
||||
// Reset state; skip this iteration.
|
||||
*skip_next = None;
|
||||
return Some(None);
|
||||
}
|
||||
|
||||
// Mark the next item as (to be) skipped.
|
||||
if arg == "--index-url" || arg == "--extra-index-url" {
|
||||
if arg == "--index-url"
|
||||
|| arg == "--extra-index-url"
|
||||
|| arg == "-i"
|
||||
|| arg == "--index"
|
||||
|| arg == "--default-index"
|
||||
{
|
||||
*skip_next = Some(true);
|
||||
return Some(None);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5459,45 +5459,385 @@ fn resolver_legacy() -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Emit the `--index-url` and `--extra-index-url` locations.
|
||||
/// Also, preserve the `--index-url` and `--extra-index-url` flags in the command in the header.
|
||||
/// Avoid including the `--index` and `-i` flags in the header.
|
||||
#[test]
|
||||
fn hide_index_urls() -> Result<()> {
|
||||
let context = TestContext::new("3.12");
|
||||
let requirements_in = context.temp_dir.child("requirements.in");
|
||||
requirements_in.write_str("iniconfig")?;
|
||||
|
||||
uv_snapshot!(context.filters(), context.pip_compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--default-index")
|
||||
.arg("https://test.pypi.org/simple/"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] requirements.in
|
||||
iniconfig==2.0.0
|
||||
# via -r requirements.in
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
uv_snapshot!(context.filters(), context.pip_compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--default-index=https://test.pypi.org/simple/"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] requirements.in
|
||||
iniconfig==2.0.0
|
||||
# via -r requirements.in
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
uv_snapshot!(context.filters(), context.pip_compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--index")
|
||||
.arg("https://test.pypi.org/simple/"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] requirements.in
|
||||
iniconfig==2.0.0
|
||||
# via -r requirements.in
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
uv_snapshot!(context.filters(), context.pip_compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--index=https://test.pypi.org/simple/"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] requirements.in
|
||||
iniconfig==2.0.0
|
||||
# via -r requirements.in
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
uv_snapshot!(context.filters(), context.pip_compile()
|
||||
.arg("requirements.in")
|
||||
.arg("-i")
|
||||
.arg("https://test.pypi.org/simple/"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] requirements.in
|
||||
iniconfig==2.0.0
|
||||
# via -r requirements.in
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
uv_snapshot!(context.filters(), context.pip_compile()
|
||||
.arg("requirements.in")
|
||||
.arg("-i=https://test.pypi.org/simple/"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] requirements.in
|
||||
iniconfig==2.0.0
|
||||
# via -r requirements.in
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
uv_snapshot!(context.filters(), context.pip_compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--index-url")
|
||||
.arg("https://test.pypi.org/simple/"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] requirements.in
|
||||
iniconfig==2.0.0
|
||||
# via -r requirements.in
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
uv_snapshot!(context.filters(), context.pip_compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--index-url=https://test.pypi.org/simple/"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] requirements.in
|
||||
iniconfig==2.0.0
|
||||
# via -r requirements.in
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
uv_snapshot!(context.filters(), context.pip_compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--extra-index-url")
|
||||
.arg("https://test.pypi.org/simple/"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] requirements.in
|
||||
iniconfig==2.0.0
|
||||
# via -r requirements.in
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
uv_snapshot!(context.filters(), context.pip_compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--extra-index-url=https://test.pypi.org/simple/"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] requirements.in
|
||||
iniconfig==2.0.0
|
||||
# via -r requirements.in
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Emit the `--index-url` and `--extra-index-url` locations, and preserve the `--index-url` and
|
||||
/// `--extra-index-url` flags in the command in the header.
|
||||
#[test]
|
||||
fn emit_index_urls() -> Result<()> {
|
||||
let context = TestContext::new("3.12");
|
||||
let requirements_in = context.temp_dir.child("requirements.in");
|
||||
requirements_in.write_str("black==23.10.1")?;
|
||||
requirements_in.write_str("iniconfig")?;
|
||||
|
||||
uv_snapshot!(context.filters(), context.pip_compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--emit-index-url")
|
||||
.arg("--default-index")
|
||||
.arg("https://test.pypi.org/simple/"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] requirements.in --emit-index-url --default-index https://test.pypi.org/simple/
|
||||
--index-url https://test.pypi.org/simple/
|
||||
|
||||
iniconfig==2.0.0
|
||||
# via -r requirements.in
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
uv_snapshot!(context.filters(), context.pip_compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--emit-index-url")
|
||||
.arg("--default-index=https://test.pypi.org/simple/"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] requirements.in --emit-index-url --default-index=https://test.pypi.org/simple/
|
||||
--index-url https://test.pypi.org/simple/
|
||||
|
||||
iniconfig==2.0.0
|
||||
# via -r requirements.in
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
uv_snapshot!(context.filters(), context.pip_compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--emit-index-url")
|
||||
.arg("--index")
|
||||
.arg("https://test.pypi.org/simple/"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] requirements.in --emit-index-url --index https://test.pypi.org/simple/
|
||||
--index-url https://pypi.org/simple
|
||||
--extra-index-url https://test.pypi.org/simple/
|
||||
|
||||
iniconfig==2.0.0
|
||||
# via -r requirements.in
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
uv_snapshot!(context.filters(), context.pip_compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--emit-index-url")
|
||||
.arg("--index=https://test.pypi.org/simple/"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] requirements.in --emit-index-url --index=https://test.pypi.org/simple/
|
||||
--index-url https://pypi.org/simple
|
||||
--extra-index-url https://test.pypi.org/simple/
|
||||
|
||||
iniconfig==2.0.0
|
||||
# via -r requirements.in
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
uv_snapshot!(context.filters(), context.pip_compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--emit-index-url")
|
||||
.arg("-i")
|
||||
.arg("https://test.pypi.org/simple/"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] requirements.in --emit-index-url -i https://test.pypi.org/simple/
|
||||
--index-url https://test.pypi.org/simple/
|
||||
|
||||
iniconfig==2.0.0
|
||||
# via -r requirements.in
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
uv_snapshot!(context.filters(), context.pip_compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--emit-index-url")
|
||||
.arg("-i=https://test.pypi.org/simple/"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] requirements.in --emit-index-url -i=https://test.pypi.org/simple/
|
||||
--index-url https://test.pypi.org/simple/
|
||||
|
||||
iniconfig==2.0.0
|
||||
# via -r requirements.in
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
uv_snapshot!(context.filters(), context.pip_compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--emit-index-url")
|
||||
.arg("--index-url")
|
||||
.arg("https://test.pypi.org/simple/")
|
||||
.arg("--extra-index-url")
|
||||
.arg("https://pypi.org/simple")
|
||||
.env(EnvVars::UV_EXTRA_INDEX_URL, "https://pypi.org/simple"), @r###"
|
||||
.arg("https://test.pypi.org/simple/"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] requirements.in --emit-index-url --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple
|
||||
# uv pip compile --cache-dir [CACHE_DIR] requirements.in --emit-index-url --index-url https://test.pypi.org/simple/
|
||||
--index-url https://test.pypi.org/simple/
|
||||
--extra-index-url https://pypi.org/simple
|
||||
|
||||
black==23.10.1
|
||||
iniconfig==2.0.0
|
||||
# via -r requirements.in
|
||||
click==8.1.7
|
||||
# via black
|
||||
mypy-extensions==1.0.0
|
||||
# via black
|
||||
packaging==24.0
|
||||
# via black
|
||||
pathspec==0.12.1
|
||||
# via black
|
||||
platformdirs==4.2.0
|
||||
# via black
|
||||
|
||||
----- stderr -----
|
||||
Resolved 6 packages in [TIME]
|
||||
Resolved 1 package in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
uv_snapshot!(context.filters(), context.pip_compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--emit-index-url")
|
||||
.arg("--index-url=https://test.pypi.org/simple/"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] requirements.in --emit-index-url --index-url=https://test.pypi.org/simple/
|
||||
--index-url https://test.pypi.org/simple/
|
||||
|
||||
iniconfig==2.0.0
|
||||
# via -r requirements.in
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
uv_snapshot!(context.filters(), context.pip_compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--emit-index-url")
|
||||
.arg("--extra-index-url")
|
||||
.arg("https://test.pypi.org/simple/"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] requirements.in --emit-index-url --extra-index-url https://test.pypi.org/simple/
|
||||
--index-url https://pypi.org/simple
|
||||
--extra-index-url https://test.pypi.org/simple/
|
||||
|
||||
iniconfig==2.0.0
|
||||
# via -r requirements.in
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
uv_snapshot!(context.filters(), context.pip_compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--emit-index-url")
|
||||
.arg("--extra-index-url=https://test.pypi.org/simple/"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] requirements.in --emit-index-url --extra-index-url=https://test.pypi.org/simple/
|
||||
--index-url https://pypi.org/simple
|
||||
--extra-index-url https://test.pypi.org/simple/
|
||||
|
||||
iniconfig==2.0.0
|
||||
# via -r requirements.in
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue