diff --git a/src/bin/cargo/commands/add.rs b/src/bin/cargo/commands/add.rs index 32c7699e775e..13c1e09d8c1a 100644 --- a/src/bin/cargo/commands/add.rs +++ b/src/bin/cargo/commands/add.rs @@ -7,6 +7,7 @@ use cargo::ops::cargo_add::add; use cargo::ops::cargo_add::AddOptions; use cargo::ops::cargo_add::DepOp; use cargo::ops::cargo_add::DepTable; +use cargo::ops::generate_lockfile; use cargo::util::command_prelude::*; use cargo::util::interning::InternedString; use cargo::CargoResult; @@ -193,6 +194,12 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { }; add(&ws, &options)?; + if !dry_run { + // Reload the workspace since we've changed dependencies + let ws = args.workspace(config)?; + generate_lockfile(&ws)?; + } + Ok(()) } diff --git a/tests/testsuite/cargo_add/git/stderr.log b/tests/testsuite/cargo_add/git/stderr.log index fdfb1a952a16..839d8bb32727 100644 --- a/tests/testsuite/cargo_add/git/stderr.log +++ b/tests/testsuite/cargo_add/git/stderr.log @@ -1,2 +1,3 @@ Updating git repository `[ROOTURL]/git-package` Adding git-package (git) to dependencies. + Updating git repository `[ROOTURL]/git-package` diff --git a/tests/testsuite/cargo_add/git_branch/stderr.log b/tests/testsuite/cargo_add/git_branch/stderr.log index fdfb1a952a16..839d8bb32727 100644 --- a/tests/testsuite/cargo_add/git_branch/stderr.log +++ b/tests/testsuite/cargo_add/git_branch/stderr.log @@ -1,2 +1,3 @@ Updating git repository `[ROOTURL]/git-package` Adding git-package (git) to dependencies. + Updating git repository `[ROOTURL]/git-package` diff --git a/tests/testsuite/cargo_add/git_dev/stderr.log b/tests/testsuite/cargo_add/git_dev/stderr.log index 4ba31625b58e..8e53bb4beeae 100644 --- a/tests/testsuite/cargo_add/git_dev/stderr.log +++ b/tests/testsuite/cargo_add/git_dev/stderr.log @@ -1,2 +1,3 @@ Updating git repository `[ROOTURL]/git-package` Adding git-package (git) to dev-dependencies. + Updating git repository `[ROOTURL]/git-package` diff --git a/tests/testsuite/cargo_add/git_inferred_name/stderr.log b/tests/testsuite/cargo_add/git_inferred_name/stderr.log index 48f251ea11d7..b5e8b1c9ba39 100644 --- a/tests/testsuite/cargo_add/git_inferred_name/stderr.log +++ b/tests/testsuite/cargo_add/git_inferred_name/stderr.log @@ -1,3 +1,4 @@ Updating git repository `[ROOTURL]/git-package` Updating git repository `[ROOTURL]/git-package` Adding git-package (git) to dependencies. + Updating git repository `[ROOTURL]/git-package` diff --git a/tests/testsuite/cargo_add/git_multiple_names/stderr.log b/tests/testsuite/cargo_add/git_multiple_names/stderr.log index e67710147dac..454f0c797ee7 100644 --- a/tests/testsuite/cargo_add/git_multiple_names/stderr.log +++ b/tests/testsuite/cargo_add/git_multiple_names/stderr.log @@ -1,3 +1,4 @@ Updating git repository `[ROOTURL]/git-package` Adding my-package1 (git) to dependencies. Adding my-package2 (git) to dependencies. + Updating git repository `[ROOTURL]/git-package` diff --git a/tests/testsuite/cargo_add/git_registry/mod.rs b/tests/testsuite/cargo_add/git_registry/mod.rs index 20ebb39a8489..b546f63abef9 100644 --- a/tests/testsuite/cargo_add/git_registry/mod.rs +++ b/tests/testsuite/cargo_add/git_registry/mod.rs @@ -32,7 +32,7 @@ fn git_registry() { ]) .current_dir(cwd) .assert() - .success() + .failure() .stdout_matches_path(curr_dir!().join("stdout.log")) .stderr_matches_path(curr_dir!().join("stderr.log")); diff --git a/tests/testsuite/cargo_add/git_registry/stderr.log b/tests/testsuite/cargo_add/git_registry/stderr.log index 548debfadf6a..c554c7ec0827 100644 --- a/tests/testsuite/cargo_add/git_registry/stderr.log +++ b/tests/testsuite/cargo_add/git_registry/stderr.log @@ -1,2 +1,6 @@ Updating git repository `[ROOTURL]/versioned-package` Adding versioned-package (git) to dependencies. +error: failed to parse manifest at `[ROOT]/case/Cargo.toml` + +Caused by: + dependency (versioned-package) specification is ambiguous. Only one of `git` or `registry` is allowed. diff --git a/tests/testsuite/cargo_add/git_rev/stderr.log b/tests/testsuite/cargo_add/git_rev/stderr.log index fdfb1a952a16..839d8bb32727 100644 --- a/tests/testsuite/cargo_add/git_rev/stderr.log +++ b/tests/testsuite/cargo_add/git_rev/stderr.log @@ -1,2 +1,3 @@ Updating git repository `[ROOTURL]/git-package` Adding git-package (git) to dependencies. + Updating git repository `[ROOTURL]/git-package` diff --git a/tests/testsuite/cargo_add/git_tag/stderr.log b/tests/testsuite/cargo_add/git_tag/stderr.log index fdfb1a952a16..839d8bb32727 100644 --- a/tests/testsuite/cargo_add/git_tag/stderr.log +++ b/tests/testsuite/cargo_add/git_tag/stderr.log @@ -1,2 +1,3 @@ Updating git repository `[ROOTURL]/git-package` Adding git-package (git) to dependencies. + Updating git repository `[ROOTURL]/git-package` diff --git a/tests/testsuite/cargo_add/list_features_path/stderr.log b/tests/testsuite/cargo_add/list_features_path/stderr.log index 27378049be00..af6747fe8360 100644 --- a/tests/testsuite/cargo_add/list_features_path/stderr.log +++ b/tests/testsuite/cargo_add/list_features_path/stderr.log @@ -4,3 +4,4 @@ + nose - eyes - optional-dependency + Updating `dummy-registry` index diff --git a/tests/testsuite/cargo_add/list_features_path_no_default/stderr.log b/tests/testsuite/cargo_add/list_features_path_no_default/stderr.log index cc6c83462791..7f47a220ec09 100644 --- a/tests/testsuite/cargo_add/list_features_path_no_default/stderr.log +++ b/tests/testsuite/cargo_add/list_features_path_no_default/stderr.log @@ -4,3 +4,4 @@ - mouth - nose - optional-dependency + Updating `dummy-registry` index diff --git a/tests/testsuite/cargo_add/locked_unchanged/in/Cargo.lock b/tests/testsuite/cargo_add/locked_unchanged/in/Cargo.lock new file mode 100644 index 000000000000..011b335926ee --- /dev/null +++ b/tests/testsuite/cargo_add/locked_unchanged/in/Cargo.lock @@ -0,0 +1,16 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "cargo-list-test-fixture" +version = "0.0.0" +dependencies = [ + "my-package", +] + +[[package]] +name = "my-package" +version = "99999.0.0+my-package" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62c45acf9e11d2f97f5b318143219c0b4102eafef1c22a4b545b47104691d915" diff --git a/tests/testsuite/cargo_add/overwrite_version_with_git/stderr.log b/tests/testsuite/cargo_add/overwrite_version_with_git/stderr.log index c5013969264d..1b77cbe0e358 100644 --- a/tests/testsuite/cargo_add/overwrite_version_with_git/stderr.log +++ b/tests/testsuite/cargo_add/overwrite_version_with_git/stderr.log @@ -1,2 +1,3 @@ Updating git repository `[ROOTURL]/versioned-package` Adding versioned-package (git) to optional dependencies. + Updating git repository `[ROOTURL]/versioned-package`