Rename uv add --raw to --raw-sources (#4538)

## Summary

This feels a bit clearer and less ambiguous.
This commit is contained in:
Ibraheem Ahmed 2024-06-26 14:50:04 -04:00 committed by GitHub
parent d4fd868531
commit fe13ea39f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 11 additions and 11 deletions

View file

@ -1757,7 +1757,7 @@ pub struct AddArgs {
///
/// Without this flag uv will try to use `tool.uv.sources` for any sources.
#[arg(long)]
pub raw: bool,
pub raw_sources: bool,
/// Specific commit to use when adding from Git.
#[arg(long)]

View file

@ -28,7 +28,7 @@ pub(crate) async fn add(
requirements: Vec<RequirementsSource>,
dev: bool,
editable: Option<bool>,
raw: bool,
raw_sources: bool,
rev: Option<String>,
tag: Option<String>,
branch: Option<String>,
@ -148,7 +148,7 @@ pub(crate) async fn add(
// Add the requirements to the `pyproject.toml`.
let mut pyproject = PyProjectTomlMut::from_toml(project.current_project().pyproject_toml())?;
for req in requirements {
let (req, source) = if raw {
let (req, source) = if raw_sources {
// Use the PEP 508 requirement directly.
(pep508_rs::Requirement::from(req), None)
} else {
@ -167,7 +167,7 @@ pub(crate) async fn add(
let source = match result {
Ok(source) => source,
Err(SourceError::UnresolvedReference(rev)) => {
anyhow::bail!("Cannot resolve Git reference `{rev}` for requirement `{}`. Specify the reference with one of `--tag`, `--branch`, or `--rev`, or use the `--raw` flag.", req.name)
anyhow::bail!("Cannot resolve Git reference `{rev}` for requirement `{}`. Specify the reference with one of `--tag`, `--branch`, or `--rev`, or use the `--raw-sources` flag.", req.name)
}
Err(err) => return Err(err.into()),
};

View file

@ -721,7 +721,7 @@ async fn run() -> Result<ExitStatus> {
args.requirements,
args.dev,
args.editable,
args.raw,
args.raw_sources,
args.rev,
args.tag,
args.branch,

View file

@ -433,7 +433,7 @@ pub(crate) struct AddSettings {
pub(crate) requirements: Vec<RequirementsSource>,
pub(crate) dev: bool,
pub(crate) editable: Option<bool>,
pub(crate) raw: bool,
pub(crate) raw_sources: bool,
pub(crate) rev: Option<String>,
pub(crate) tag: Option<String>,
pub(crate) branch: Option<String>,
@ -451,7 +451,7 @@ impl AddSettings {
requirements,
dev,
editable,
raw,
raw_sources,
rev,
tag,
branch,
@ -471,7 +471,7 @@ impl AddSettings {
requirements,
dev,
editable,
raw,
raw_sources,
rev,
tag,
branch,

View file

@ -167,7 +167,7 @@ fn add_git() -> Result<()> {
----- stdout -----
----- stderr -----
error: Cannot resolve Git reference `0.0.1` for requirement `uv-public-pypackage`. Specify the reference with one of `--tag`, `--branch`, or `--rev`, or use the `--raw` flag.
error: Cannot resolve Git reference `0.0.1` for requirement `uv-public-pypackage`. Specify the reference with one of `--tag`, `--branch`, or `--rev`, or use the `--raw-sources` flag.
"###);
uv_snapshot!(context.filters(), context.add(&["uv-public-pypackage @ git+https://github.com/astral-test/uv-public-pypackage"]).arg("--tag=0.0.1").arg("--preview"), @r###"
@ -277,7 +277,7 @@ fn add_git() -> Result<()> {
Ok(())
}
/// Add a Git requirement using the `--raw` API.
/// Add a Git requirement using the `--raw-sources` API.
#[test]
fn add_git_raw() -> Result<()> {
let context = TestContext::new("3.12");
@ -317,7 +317,7 @@ fn add_git_raw() -> Result<()> {
"###);
// Use an ambiguous tag reference, which would otherwise not resolve.
uv_snapshot!(context.filters(), context.add(&["uv-public-pypackage @ git+https://github.com/astral-test/uv-public-pypackage@0.0.1"]).arg("--raw").arg("--preview"), @r###"
uv_snapshot!(context.filters(), context.add(&["uv-public-pypackage @ git+https://github.com/astral-test/uv-public-pypackage@0.0.1"]).arg("--raw-sources").arg("--preview"), @r###"
success: true
exit_code: 0
----- stdout -----