]> git.proxmox.com Git - cargo.git/commitdiff
fix(add): Clarify which version the features are added for
authorEd Page <eopage@gmail.com>
Mon, 12 Sep 2022 14:37:05 +0000 (09:37 -0500)
committerEd Page <eopage@gmail.com>
Mon, 12 Sep 2022 14:39:47 +0000 (09:39 -0500)
This gives a hint to users that we might not be showing the feature list
for the latest version but the earliest version.

Also when using a workspace dependency or re-using an existing
dependency, this is a good reminder of what the version requirement is
that was selected.

However, when the user or add (the common case) selected a full
precision requirement, this is redundant.

I'm also mixed on whether the meta version should show up.

Fixes #11073

26 files changed:
src/cargo/ops/cargo_add/mod.rs
tests/testsuite/cargo_add/add_normalized_name_external/stderr.log
tests/testsuite/cargo_add/build_prefer_existing_version/stderr.log
tests/testsuite/cargo_add/detect_workspace_inherit_features/stderr.log
tests/testsuite/cargo_add/dev_prefer_existing_version/stderr.log
tests/testsuite/cargo_add/features/stderr.log
tests/testsuite/cargo_add/features_empty/stderr.log
tests/testsuite/cargo_add/features_multiple_occurrences/stderr.log
tests/testsuite/cargo_add/features_preserve/stderr.log
tests/testsuite/cargo_add/features_spaced_values/stderr.log
tests/testsuite/cargo_add/features_unknown/stderr.log
tests/testsuite/cargo_add/list_features/stderr.log
tests/testsuite/cargo_add/list_features_path/stderr.log
tests/testsuite/cargo_add/list_features_path_no_default/stderr.log
tests/testsuite/cargo_add/merge_activated_features/stderr.log
tests/testsuite/cargo_add/overwrite_features/stderr.log
tests/testsuite/cargo_add/overwrite_inherit_features_noop/stderr.log
tests/testsuite/cargo_add/overwrite_inline_features/stderr.log
tests/testsuite/cargo_add/overwrite_name_dev_noop/stderr.log
tests/testsuite/cargo_add/overwrite_name_noop/stderr.log
tests/testsuite/cargo_add/overwrite_optional_with_no_optional/stderr.log
tests/testsuite/cargo_add/overwrite_path_noop/stderr.log
tests/testsuite/cargo_add/overwrite_preserves_inline_table/stderr.log
tests/testsuite/cargo_add/overwrite_workspace_dep_features/stderr.log
tests/testsuite/cargo_add/require_weak/stderr.log
tests/testsuite/cargo_add/unknown_inherited_feature/stderr.log

index 08695525be171980d429a76ff2cb0916c9da6fa7..7012e3bcb177ad01e461e73451aaeb8a4f829eee 100644 (file)
@@ -601,6 +601,7 @@ fn populate_dependency(mut dependency: Dependency, arg: &DepOp) -> Dependency {
 
 pub struct DependencyEx {
     dep: Dependency,
+    available_version: Option<semver::Version>,
     available_features: BTreeMap<String, Vec<String>>,
 }
 
@@ -608,11 +609,13 @@ impl DependencyEx {
     fn new(dep: Dependency) -> Self {
         Self {
             dep,
+            available_version: None,
             available_features: Default::default(),
         }
     }
 
     fn apply_summary(&mut self, summary: &Summary) {
+        self.available_version = Some(summary.version().clone());
         self.available_features = summary
             .features()
             .iter()
@@ -765,7 +768,15 @@ fn print_msg(shell: &mut Shell, dep: &DependencyEx, section: &[String]) -> Cargo
     deactivated.sort();
     if !activated.is_empty() || !deactivated.is_empty() {
         let prefix = format!("{:>13}", " ");
-        shell.write_stderr(format_args!("{}Features:\n", prefix), &ColorSpec::new())?;
+        let suffix = if let Some(version) = &dep.available_version {
+            format!(" as of v{}", version)
+        } else {
+            "".to_owned()
+        };
+        shell.write_stderr(
+            format_args!("{}Features{}:\n", prefix, suffix),
+            &ColorSpec::new(),
+        )?;
         for feat in activated {
             shell.write_stderr(&prefix, &ColorSpec::new())?;
             shell.write_stderr('+', &ColorSpec::new().set_bold(true).set_fg(Some(Green)))?;
index c7d45114329761e8cbcf563c2d40bfb4975d75dc..9f7fc219e1468850da290ea5444349af8e7e37b0 100644 (file)
@@ -2,7 +2,7 @@
 warning: translating `linked_hash_map` to `linked-hash-map`
 warning: translating `Inflector` to `inflector`
       Adding linked-hash-map v0.5.4 to dependencies.
-             Features:
+             Features as of v0.5.4:
              - clippy
              - heapsize
              - heapsize_impl
@@ -11,7 +11,7 @@ warning: translating `Inflector` to `inflector`
              - serde_impl
              - serde_test
       Adding inflector v0.11.4 to dependencies.
-             Features:
+             Features as of v0.11.4:
              + heavyweight
              + lazy_static
              + regex
index 554aa2ef31d255910070c9709a614157137e358f..ba6d8507075524abbfd1fbbc5aff5eea246be0a2 100644 (file)
@@ -1,4 +1,4 @@
       Adding cargo-list-test-fixture-dependency (local) to build-dependencies.
-             Features:
+             Features as of v0.0.0:
              - one
              - two
index 86d9fb3b85707a868e051f6a6e62b93773c5863d..02dde7a34417b6891d8264ee5c55f2f46a34e55b 100644 (file)
@@ -1,5 +1,5 @@
       Adding foo (workspace) to dependencies.
-             Features:
+             Features as of v0.0.0:
              + default-base
              + default-merge-base
              + default-test-base
index 06673543a9f9084ca7d78a506039fa23d8b2e9ea..32f9a3e82f41001bc685ab8fdc32bdfe99ddd586 100644 (file)
@@ -1,4 +1,4 @@
       Adding cargo-list-test-fixture-dependency (local) to dev-dependencies.
-             Features:
+             Features as of v0.0.0:
              - one
              - two
index 386f3db5acc161e72e1940837313e59ba5eaf837..58cfb8eeb01480ca7f0b8422bf58573584dc27f1 100644 (file)
@@ -1,6 +1,6 @@
     Updating `dummy-registry` index
       Adding your-face v99999.0.0 to dependencies.
-             Features:
+             Features as of v99999.0.0+my-package:
              + eyes
              - ears
              - mouth
index 796b9601b4dec15d01493553fc31e803cc09b477..71380066c85dd7bf9df2738a068be4c1855e7f91 100644 (file)
@@ -1,6 +1,6 @@
     Updating `dummy-registry` index
       Adding your-face v99999.0.0 to dependencies.
-             Features:
+             Features as of v99999.0.0+my-package:
              - ears
              - eyes
              - mouth
index 615459052e4eade99c318a8bddd5b70db0f820ed..618a9397b94794c895e48bb696a73f630f3ffc1a 100644 (file)
@@ -1,6 +1,6 @@
     Updating `dummy-registry` index
       Adding your-face v99999.0.0 to dependencies.
-             Features:
+             Features as of v99999.0.0+my-package:
              + eyes
              + nose
              - ears
index 386f3db5acc161e72e1940837313e59ba5eaf837..58cfb8eeb01480ca7f0b8422bf58573584dc27f1 100644 (file)
@@ -1,6 +1,6 @@
     Updating `dummy-registry` index
       Adding your-face v99999.0.0 to dependencies.
-             Features:
+             Features as of v99999.0.0+my-package:
              + eyes
              - ears
              - mouth
index 615459052e4eade99c318a8bddd5b70db0f820ed..618a9397b94794c895e48bb696a73f630f3ffc1a 100644 (file)
@@ -1,6 +1,6 @@
     Updating `dummy-registry` index
       Adding your-face v99999.0.0 to dependencies.
-             Features:
+             Features as of v99999.0.0+my-package:
              + eyes
              + nose
              - ears
index 7f59af09a6eff5166a28e5623b890bab8c0cc839..0d1f3f69a1fb8909641578c34814058ab46453a0 100644 (file)
@@ -1,6 +1,6 @@
     Updating `dummy-registry` index
       Adding your-face v99999.0.0 to dependencies.
-             Features:
+             Features as of v99999.0.0+my-package:
              + noze
              - ears
              - eyes
index 796b9601b4dec15d01493553fc31e803cc09b477..71380066c85dd7bf9df2738a068be4c1855e7f91 100644 (file)
@@ -1,6 +1,6 @@
     Updating `dummy-registry` index
       Adding your-face v99999.0.0 to dependencies.
-             Features:
+             Features as of v99999.0.0+my-package:
              - ears
              - eyes
              - mouth
index af6747fe8360007c79317606c96d4ebec2ef4ba0..60419c148626dba66747a2adafa372618c815622 100644 (file)
@@ -1,5 +1,5 @@
       Adding your-face (local) to dependencies.
-             Features:
+             Features as of v0.1.3:
              + mouth
              + nose
              - eyes
index 7f47a220ec09fbd65678a0223f721caea5f7caf3..9f63857dcaa9019f576ee1d82205e391203bbd2e 100644 (file)
@@ -1,5 +1,5 @@
       Adding your-face (local) to dependencies.
-             Features:
+             Features as of v0.1.3:
              - eyes
              - mouth
              - nose
index 86d9fb3b85707a868e051f6a6e62b93773c5863d..02dde7a34417b6891d8264ee5c55f2f46a34e55b 100644 (file)
@@ -1,5 +1,5 @@
       Adding foo (workspace) to dependencies.
-             Features:
+             Features as of v0.0.0:
              + default-base
              + default-merge-base
              + default-test-base
index 615459052e4eade99c318a8bddd5b70db0f820ed..618a9397b94794c895e48bb696a73f630f3ffc1a 100644 (file)
@@ -1,6 +1,6 @@
     Updating `dummy-registry` index
       Adding your-face v99999.0.0 to dependencies.
-             Features:
+             Features as of v99999.0.0+my-package:
              + eyes
              + nose
              - ears
index 0eee2e6bd466ee567d0b8c217d43f26fb0154224..3c7133bbc521ab1c9ad27aa619ffa7e89c2203f4 100644 (file)
@@ -1,3 +1,3 @@
       Adding foo (workspace) to dependencies.
-             Features:
+             Features as of v0.0.0:
              + test
index a686cba55d5fe39024d0657da49099f2c07de24e..b0f656df90ea0d1a23a3bd65af3bc99b8f3fdc1b 100644 (file)
@@ -1,7 +1,7 @@
     Updating `dummy-registry` index
       Adding unrelateed-crate v99999.0.0 to dependencies.
       Adding your-face v99999.0.0 to dependencies.
-             Features:
+             Features as of v99999.0.0+my-package:
              + ears
              + eyes
              + mouth
index 2fe3f6a290642a5a8d5ab0c8c58528a8f86b99e8..a9d0c65d7adeae3bf2dbadf3345c09e586eb56ef 100644 (file)
@@ -1,4 +1,4 @@
       Adding your-face (local) to dev-dependencies.
-             Features:
+             Features as of v0.0.0:
              + mouth
              + nose
index 2f0b90de0d2216d0eae9ba0d731d5084584d30b8..fdd8d51a17027ec6f471d1a742742fd68b233d86 100644 (file)
@@ -1,4 +1,4 @@
       Adding your-face (local) to optional dependencies.
-             Features:
+             Features as of v0.0.0:
              + mouth
              + nose
index 5fe113e86c76df7109da7597f569a1ccee3886b6..5ef0f6090e2a4cf60c63e87bacf133ac226d3745 100644 (file)
@@ -1,6 +1,6 @@
     Updating `dummy-registry` index
       Adding your-face v99999.0.0 to dependencies.
-             Features:
+             Features as of v99999.0.0+my-package:
              - ears
              - eyes
              - mouth
index 2f0b90de0d2216d0eae9ba0d731d5084584d30b8..fdd8d51a17027ec6f471d1a742742fd68b233d86 100644 (file)
@@ -1,4 +1,4 @@
       Adding your-face (local) to optional dependencies.
-             Features:
+             Features as of v0.0.0:
              + mouth
              + nose
index 615459052e4eade99c318a8bddd5b70db0f820ed..618a9397b94794c895e48bb696a73f630f3ffc1a 100644 (file)
@@ -1,6 +1,6 @@
     Updating `dummy-registry` index
       Adding your-face v99999.0.0 to dependencies.
-             Features:
+             Features as of v99999.0.0+my-package:
              + eyes
              + nose
              - ears
index 18ed7c2d8facae1d5137bb0c075d213b2be3ff05..e5579fda621ee6b3645dcf64ce116521e1265144 100644 (file)
@@ -1,5 +1,5 @@
       Adding foo (local) to dependencies.
-             Features:
+             Features as of v0.0.0:
              + default-base
              + default-merge-base
              + default-test-base
index 796b9601b4dec15d01493553fc31e803cc09b477..71380066c85dd7bf9df2738a068be4c1855e7f91 100644 (file)
@@ -1,6 +1,6 @@
     Updating `dummy-registry` index
       Adding your-face v99999.0.0 to dependencies.
-             Features:
+             Features as of v99999.0.0+my-package:
              - ears
              - eyes
              - mouth
index 693e88721050384f029d99f15c62a9e5e3a16afc..acc7bd2bbd0ace87009c9574748325e05bd4c50d 100644 (file)
@@ -1,5 +1,5 @@
       Adding foo (workspace) to dependencies.
-             Features:
+             Features as of v0.0.0:
              + default-base
              + default-merge-base
              + default-test-base