Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions crates/uv/src/commands/project/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,17 +708,14 @@ pub(crate) async fn add(
return Ok(ExitStatus::Success);
}

// If we're modifying a script, and lockfile doesn't exist, don't create it.
if let AddTarget::Script(ref script, _) = target {
if !LockTarget::from(script).lock_path().is_file() {
writeln!(
printer.stderr(),
"Updated `{}`",
script.path.user_display().cyan()
)?;
return Ok(ExitStatus::Success);
}
}
// If we're modifying a script, and lockfile doesn't exist, avoid creating it. We still need
// to perform resolution, since we want to use the resolved versions to populate lower bounds
// in the script.
let dry_run = if let AddTarget::Script(ref script, _) = target {
!LockTarget::from(script).lock_path().is_file()
} else {
false
};

// Update the `pypackage.toml` in-memory.
let target = target.update(&content)?;
Expand Down Expand Up @@ -763,6 +760,7 @@ pub(crate) async fn add(
&defaulted_groups,
raw,
bounds,
dry_run,
constraints,
&settings,
&client_builder,
Expand Down Expand Up @@ -1004,6 +1002,7 @@ async fn lock_and_sync(
groups: &DependencyGroupsWithDefaults,
raw: bool,
bound_kind: Option<AddBoundsKind>,
dry_run: bool,
constraints: Vec<NameRequirementSpecification>,
settings: &ResolverInstallerSettings,
client_builder: &BaseClientBuilder<'_>,
Expand All @@ -1017,6 +1016,8 @@ async fn lock_and_sync(
project::lock::LockOperation::new(
if let LockCheck::Enabled(lock_check) = lock_check {
LockMode::Locked(target.interpreter(), lock_check)
} else if dry_run {
LockMode::DryRun(target.interpreter())
} else {
LockMode::Write(target.interpreter())
},
Expand Down Expand Up @@ -1140,6 +1141,8 @@ async fn lock_and_sync(
project::lock::LockOperation::new(
if let LockCheck::Enabled(lock_check) = lock_check {
LockMode::Locked(target.interpreter(), lock_check)
} else if dry_run {
LockMode::DryRun(target.interpreter())
} else {
LockMode::Write(target.interpreter())
},
Expand Down
Loading
Loading