Skip to content

Commit 9589d2c

Browse files
committed
fix: change to update -w per feedback
1 parent 5b92843 commit 9589d2c

File tree

12 files changed

+75
-58
lines changed

12 files changed

+75
-58
lines changed

src/bin/cargo/commands/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ pub fn builtin() -> Vec<App> {
88
clean::cli(),
99
doc::cli(),
1010
fetch::cli(),
11-
sync_lockfile::cli(),
1211
fix::cli(),
1312
generate_lockfile::cli(),
1413
git_checkout::cli(),
@@ -46,7 +45,6 @@ pub fn builtin_exec(cmd: &str) -> Option<fn(&mut Config, &ArgMatches<'_>) -> Cli
4645
"clean" => clean::exec,
4746
"doc" => doc::exec,
4847
"fetch" => fetch::exec,
49-
"sync-lockfile" => sync_lockfile::exec,
5048
"fix" => fix::exec,
5149
"generate-lockfile" => generate_lockfile::exec,
5250
"git-checkout" => git_checkout::exec,
@@ -103,7 +101,6 @@ pub mod run;
103101
pub mod rustc;
104102
pub mod rustdoc;
105103
pub mod search;
106-
pub mod sync_lockfile;
107104
pub mod test;
108105
pub mod tree;
109106
pub mod uninstall;

src/bin/cargo/commands/sync_lockfile.rs

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/bin/cargo/commands/update.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub fn cli() -> App {
77
subcommand("update")
88
.about("Update dependencies as recorded in the local lock file")
99
.arg(opt("quiet", "No output printed to stdout").short("q"))
10+
.arg(opt("workspace", "Only update the workspace pakcages").short("w"))
1011
.arg_package_spec_simple("Package to update")
1112
.arg(opt(
1213
"aggressive",
@@ -30,6 +31,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
3031
precise: args.value_of("precise"),
3132
to_update: values(args, "package"),
3233
dry_run: args.is_present("dry-run"),
34+
workspace: args.is_present("workspace"),
3335
config,
3436
};
3537
ops::update_lockfile(&ws, &update_opts)?;

src/cargo/ops/cargo_generate_lockfile.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub struct UpdateOptions<'a> {
1717
pub precise: Option<&'a str>,
1818
pub aggressive: bool,
1919
pub dry_run: bool,
20+
pub workspace: bool,
2021
}
2122

2223
pub fn generate_lockfile(ws: &Workspace<'_>) -> CargoResult<()> {
@@ -35,6 +36,19 @@ pub fn generate_lockfile(ws: &Workspace<'_>) -> CargoResult<()> {
3536
}
3637

3738
pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoResult<()> {
39+
if opts.workspace {
40+
if opts.aggressive {
41+
anyhow::bail!("cannot specify aggressive for workspace updates");
42+
}
43+
if opts.precise.is_some() {
44+
anyhow::bail!("cannot specify precise for workspace updates");
45+
}
46+
47+
ws.emit_warnings()?;
48+
let (_packages, _resolve) = ops::resolve_ws(ws)?;
49+
return Ok(())
50+
}
51+
3852
if opts.aggressive && opts.precise.is_some() {
3953
anyhow::bail!("cannot specify both aggressive and precise simultaneously")
4054
}

src/cargo/ops/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ pub use self::cargo_package::{package, PackageOpts};
1515
pub use self::cargo_pkgid::pkgid;
1616
pub use self::cargo_read_manifest::{read_package, read_packages};
1717
pub use self::cargo_run::run;
18-
pub use self::cargo_sync_lockfile::{sync_lockfile, SyncLockfileOptions};
1918
pub use self::cargo_test::{run_benches, run_tests, TestOptions};
2019
pub use self::cargo_uninstall::uninstall;
2120
pub use self::fix::{fix, fix_maybe_exec_rustc, FixOptions};
@@ -42,7 +41,6 @@ mod cargo_package;
4241
mod cargo_pkgid;
4342
mod cargo_read_manifest;
4443
mod cargo_run;
45-
mod cargo_sync_lockfile;
4644
mod cargo_test;
4745
mod cargo_uninstall;
4846
mod common_for_install_and_uninstall;

src/doc/man/cargo-update.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ the package to. If the package comes from a git repository, this can be a git
4444
revision (such as a SHA hash or tag).
4545
{{/option}}
4646

47+
{{#option "`-w`" "`--workspace`" }}
48+
Attempt to update only packages defined in the workspace. Other packages
49+
are updated only if they don't already exist in the lockfile. This
50+
option is useful for updating `Cargo.lock` after you've changed version
51+
numbers in `Cargo.toml`.
52+
Cannot be used with `--precise` or `--aggressive`.
53+
{{/option}}
54+
4755
{{#option "`--dry-run`" }}
4856
Displays what would be updated, but doesn't actually write the lockfile.
4957
{{/option}}

src/doc/man/generated_txt/cargo-update.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ OPTIONS
3535
to set the package to. If the package comes from a git repository,
3636
this can be a git revision (such as a SHA hash or tag).
3737

38+
-w, --workspace
39+
Attempt to update only packages defined in the workspace. Other
40+
packages are updated only if they don't already exist in the
41+
lockfile. This option is useful for updating Cargo.lock after you've
42+
changed version numbers in Cargo.toml. Cannot be used with --precise
43+
or --aggressive.
44+
3845
--dry-run
3946
Displays what would be updated, but doesn't actually write the
4047
lockfile.

src/doc/src/commands/cargo-update.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ the package to. If the package comes from a git repository, this can be a git
4343
revision (such as a SHA hash or tag).</dd>
4444

4545

46+
<dt class="option-term" id="option-cargo-update--w"><a class="option-anchor" href="#option-cargo-update--w"></a><code>-w</code></dt>
47+
<dt class="option-term" id="option-cargo-update---workspace"><a class="option-anchor" href="#option-cargo-update---workspace"></a><code>--workspace</code></dt>
48+
<dd class="option-desc">Attempt to update only packages defined in the workspace. Other packages
49+
are updated only if they don't already exist in the lockfile. This
50+
option is useful for updating <code>Cargo.lock</code> after you've changed version
51+
numbers in <code>Cargo.toml</code>.
52+
Cannot be used with <code>--precise</code> or <code>--aggressive</code>.</dd>
53+
54+
4655
<dt class="option-term" id="option-cargo-update---dry-run"><a class="option-anchor" href="#option-cargo-update---dry-run"></a><code>--dry-run</code></dt>
4756
<dd class="option-desc">Displays what would be updated, but doesn't actually write the lockfile.</dd>
4857

src/etc/man/cargo-update.1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ the package to. If the package comes from a git repository, this can be a git
4242
revision (such as a SHA hash or tag).
4343
.RE
4444
.sp
45+
\fB\-w\fR,
46+
\fB\-\-workspace\fR
47+
.RS 4
48+
Attempt to update only packages defined in the workspace. Other packages
49+
are updated only if they don't already exist in the lockfile. This
50+
option is useful for updating \fBCargo.lock\fR after you've changed version
51+
numbers in \fBCargo.toml\fR\&.
52+
Cannot be used with \fB\-\-precise\fR or \fB\-\-aggressive\fR\&.
53+
.RE
54+
.sp
4555
\fB\-\-dry\-run\fR
4656
.RS 4
4757
Displays what would be updated, but doesn't actually write the lockfile.

tests/testsuite/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ mod rustflags;
109109
mod search;
110110
mod shell_quoting;
111111
mod standard_lib;
112-
mod sync_lockfile;
113112
mod test;
114113
mod timings;
115114
mod tool_paths;

0 commit comments

Comments
 (0)