]> git.proxmox.com Git - cargo.git/commitdiff
Include the publish field in cargo-metadata output
authorSteven Fackler <sfackler@palantir.com>
Wed, 11 Sep 2019 18:46:12 +0000 (14:46 -0400)
committerSteven Fackler <sfackler@palantir.com>
Wed, 11 Sep 2019 18:46:12 +0000 (14:46 -0400)
src/cargo/core/package.rs
tests/testsuite/alt_registry.rs
tests/testsuite/metadata.rs
tests/testsuite/read_manifest.rs
tests/testsuite/update.rs

index db6c36f5507b1206e7a974fb20e033913128cb23..66237a8dfc6f94ef4b55f4b8488045dedca87580 100644 (file)
@@ -67,6 +67,7 @@ struct SerializedPackage<'a> {
     features: &'a FeatureMap,
     manifest_path: &'a Path,
     metadata: Option<&'a toml::Value>,
+    publish: Option<&'a Vec<String>>,
     authors: &'a [String],
     categories: &'a [String],
     keywords: &'a [String],
@@ -125,6 +126,7 @@ impl ser::Serialize for Package {
             edition: &self.manifest.edition().to_string(),
             links: self.manifest.links(),
             metabuild: self.manifest.metabuild(),
+            publish: self.publish().as_ref(),
         }
         .serialize(s)
     }
index edeb67a6b7dffcc87521e956595b848fe3f7e0d8..fd5729e6073e08833adc3b8e8f7620e12a04079c 100644 (file)
@@ -824,6 +824,7 @@ fn alt_reg_metadata() {
                         "features": {},
                         "manifest_path": "[..]/foo/Cargo.toml",
                         "metadata": null,
+                        "publish": null,
                         "authors": [],
                         "categories": [],
                         "keywords": [],
@@ -863,6 +864,7 @@ fn alt_reg_metadata() {
                         "features": {},
                         "manifest_path": "[..]/altdep2-0.0.1/Cargo.toml",
                         "metadata": null,
+                        "publish": null,
                         "authors": [],
                         "categories": [],
                         "keywords": [],
@@ -897,6 +899,7 @@ fn alt_reg_metadata() {
                         "features": {},
                         "manifest_path": "[..]/altdep-0.0.1/Cargo.toml",
                         "metadata": null,
+                        "publish": null,
                         "authors": [],
                         "categories": [],
                         "keywords": [],
@@ -943,6 +946,7 @@ fn alt_reg_metadata() {
                         "features": {},
                         "manifest_path": "[..]/foo/Cargo.toml",
                         "metadata": null,
+                        "publish": null,
                         "authors": [],
                         "categories": [],
                         "keywords": [],
@@ -977,6 +981,7 @@ fn alt_reg_metadata() {
                         "features": {},
                         "manifest_path": "[..]/iodep-0.0.1/Cargo.toml",
                         "metadata": null,
+                        "publish": null,
                         "authors": [],
                         "categories": [],
                         "keywords": [],
@@ -998,6 +1003,7 @@ fn alt_reg_metadata() {
                         "features": {},
                         "manifest_path": "[..]/bar-0.0.1/Cargo.toml",
                         "metadata": null,
+                        "publish": null,
                         "authors": [],
                         "categories": [],
                         "keywords": [],
@@ -1076,6 +1082,7 @@ fn unknown_registry() {
                   "features": {},
                   "manifest_path": "[..]",
                   "metadata": null,
+                  "publish": null,
                   "authors": [],
                   "categories": [],
                   "keywords": [],
@@ -1110,6 +1117,7 @@ fn unknown_registry() {
                   "features": {},
                   "manifest_path": "[..]/foo/Cargo.toml",
                   "metadata": null,
+                  "publish": null,
                   "authors": [],
                   "categories": [],
                   "keywords": [],
@@ -1144,6 +1152,7 @@ fn unknown_registry() {
                   "features": {},
                   "manifest_path": "[..]",
                   "metadata": null,
+                  "publish": null,
                   "authors": [],
                   "categories": [],
                   "keywords": [],
index 10f5636c67dacab4b86ee811ef34330ad0e360ea..713c9d4a83ad6f604ebb4bdba11973b623490409 100644 (file)
@@ -47,7 +47,8 @@ fn cargo_metadata_simple() {
                 ],
                 "features": {},
                 "manifest_path": "[..]Cargo.toml",
-                "metadata": null
+                "metadata": null,
+                "publish": null
             }
         ],
         "workspace_members": ["foo 0.5.0 (path+file:[..]foo)"],
@@ -138,7 +139,8 @@ crate-type = ["lib", "staticlib"]
                 ],
                 "features": {},
                 "manifest_path": "[..]Cargo.toml",
-                "metadata": null
+                "metadata": null,
+                "publish": null
             }
         ],
         "workspace_members": ["foo 0.5.0 (path+file:[..]foo)"],
@@ -223,7 +225,8 @@ optional_feat = []
                   "optional_feat": []
                 },
                 "manifest_path": "[..]Cargo.toml",
-                "metadata": null
+                "metadata": null,
+                "publish": null
             }
         ],
         "workspace_members": ["foo 0.5.0 (path+file:[..]foo)"],
@@ -296,6 +299,7 @@ fn cargo_metadata_with_deps_and_version() {
                 "links": null,
                 "manifest_path": "[..]Cargo.toml",
                 "metadata": null,
+                "publish": null,
                 "name": "baz",
                 "readme": null,
                 "repository": null,
@@ -355,6 +359,7 @@ fn cargo_metadata_with_deps_and_version() {
                 "links": null,
                 "manifest_path": "[..]Cargo.toml",
                 "metadata": null,
+                "publish": null,
                 "name": "foo",
                 "readme": null,
                 "repository": null,
@@ -389,6 +394,7 @@ fn cargo_metadata_with_deps_and_version() {
                 "links": null,
                 "manifest_path": "[..]Cargo.toml",
                 "metadata": null,
+                "publish": null,
                 "name": "foobar",
                 "readme": null,
                 "repository": null,
@@ -436,6 +442,7 @@ fn cargo_metadata_with_deps_and_version() {
                 "links": null,
                 "manifest_path": "[..]Cargo.toml",
                 "metadata": null,
+                "publish": null,
                 "name": "bar",
                 "readme": null,
                 "repository": null,
@@ -575,7 +582,8 @@ name = "ex"
                 ],
                 "features": {},
                 "manifest_path": "[..]Cargo.toml",
-                "metadata": null
+                "metadata": null,
+                "publish": null
             }
         ],
         "workspace_members": [
@@ -660,7 +668,8 @@ crate-type = ["rlib", "dylib"]
                 ],
                 "features": {},
                 "manifest_path": "[..]Cargo.toml",
-                "metadata": null
+                "metadata": null,
+                "publish": null
             }
         ],
         "workspace_members": [
@@ -736,7 +745,8 @@ fn workspace_metadata() {
                 ],
                 "features": {},
                 "manifest_path": "[..]bar/Cargo.toml",
-                "metadata": null
+                "metadata": null,
+                "publish": null
             },
             {
                 "authors": [
@@ -768,7 +778,8 @@ fn workspace_metadata() {
                 ],
                 "features": {},
                 "manifest_path": "[..]baz/Cargo.toml",
-                "metadata": null
+                "metadata": null,
+                "publish": null
             }
         ],
         "workspace_members": ["baz 0.5.0 (path+file:[..]baz)", "bar 0.5.0 (path+file:[..]bar)"],
@@ -848,7 +859,8 @@ fn workspace_metadata_no_deps() {
                 ],
                 "features": {},
                 "manifest_path": "[..]bar/Cargo.toml",
-                "metadata": null
+                "metadata": null,
+                "publish": null
             },
             {
                 "authors": [
@@ -880,7 +892,8 @@ fn workspace_metadata_no_deps() {
                 ],
                 "features": {},
                 "manifest_path": "[..]baz/Cargo.toml",
-                "metadata": null
+                "metadata": null,
+                "publish": null
             }
         ],
         "workspace_members": ["baz 0.5.0 (path+file:[..]baz)", "bar 0.5.0 (path+file:[..]bar)"],
@@ -938,6 +951,7 @@ const MANIFEST_OUTPUT: &str = r#"
         "features":{},
         "manifest_path":"[..]Cargo.toml",
         "metadata": null,
+        "publish": null,
         "readme": null,
         "repository": null
     }],
@@ -1121,7 +1135,75 @@ fn package_metadata() {
                     "bar": {
                         "baz": "quux"
                     }
-                }
+                },
+                "publish": null
+            }
+        ],
+        "workspace_members": ["foo[..]"],
+        "resolve": null,
+        "target_directory": "[..]foo/target",
+        "version": 1,
+        "workspace_root": "[..]/foo"
+    }"#,
+        )
+        .run();
+}
+
+#[cargo_test]
+fn package_publish() {
+    let p = project()
+        .file(
+            "Cargo.toml",
+            r#"
+            [package]
+            name = "foo"
+            version = "0.1.0"
+            authors = ["wycats@example.com"]
+            categories = ["database"]
+            keywords = ["database"]
+            readme = "README.md"
+            repository = "https://github.com/rust-lang/cargo"
+            publish = ["my-registry"]
+        "#,
+        )
+        .file("src/lib.rs", "")
+        .build();
+
+    p.cargo("metadata --no-deps")
+        .with_json(
+            r#"
+    {
+        "packages": [
+            {
+                "authors": ["wycats@example.com"],
+                "categories": ["database"],
+                "name": "foo",
+                "readme": "README.md",
+                "repository": "https://github.com/rust-lang/cargo",
+                "version": "0.1.0",
+                "id": "foo[..]",
+                "keywords": ["database"],
+                "source": null,
+                "dependencies": [],
+                "edition": "2015",
+                "license": null,
+                "license_file": null,
+                "links": null,
+                "description": null,
+                "targets": [
+                    {
+                        "kind": [ "lib" ],
+                        "crate_types": [ "lib" ],
+                        "doctest": true,
+                        "edition": "2015",
+                        "name": "foo",
+                        "src_path": "[..]foo/src/lib.rs"
+                    }
+                ],
+                "features": {},
+                "manifest_path": "[..]foo/Cargo.toml",
+                "metadata": null,
+                "publish": ["my-registry"]
             }
         ],
         "workspace_members": ["foo[..]"],
@@ -1175,6 +1257,7 @@ fn cargo_metadata_path_to_cargo_toml_project() {
                 "links": null,
                 "manifest_path": "[..]Cargo.toml",
                 "metadata": null,
+                "publish": null,
                 "name": "bar",
                 "readme": null,
                 "repository": null,
@@ -1255,6 +1338,7 @@ fn package_edition_2018() {
                     "links": null,
                     "manifest_path": "[..]Cargo.toml",
                     "metadata": null,
+                    "publish": null,
                     "name": "foo",
                     "readme": null,
                     "repository": null,
@@ -1339,6 +1423,7 @@ fn target_edition_2018() {
                     "links": null,
                     "manifest_path": "[..]Cargo.toml",
                     "metadata": null,
+                    "publish": null,
                     "name": "foo",
                     "readme": null,
                     "repository": null,
@@ -1461,6 +1546,7 @@ fn rename_dependency() {
             "links": null,
             "manifest_path": "[..]",
             "metadata": null,
+            "publish": null,
             "name": "foo",
             "readme": null,
             "repository": null,
@@ -1495,6 +1581,7 @@ fn rename_dependency() {
             "links": null,
             "manifest_path": "[..]",
             "metadata": null,
+            "publish": null,
             "name": "bar",
             "readme": null,
             "repository": null,
@@ -1529,6 +1616,7 @@ fn rename_dependency() {
             "links": null,
             "manifest_path": "[..]",
             "metadata": null,
+            "publish": null,
             "name": "bar",
             "readme": null,
             "repository": null,
@@ -1631,6 +1719,7 @@ fn metadata_links() {
       "links": "a",
       "manifest_path": "[..]/foo/Cargo.toml",
       "metadata": null,
+      "publish": null,
       "name": "foo",
       "readme": null,
       "repository": null,
index 61e520f14994024679ad62a11ca8c0b1a012975b..b72060f3faf7d10761c38939387868420cd0216d 100644 (file)
@@ -29,7 +29,8 @@ static MANIFEST_OUTPUT: &str = r#"
     }],
     "features":{},
     "manifest_path":"[..]Cargo.toml",
-    "metadata": null
+    "metadata": null,
+    "publish": null
 }"#;
 
 #[cargo_test]
index 468458563b05ae8a2b662ca41b284a3245e2b57b..eaeb806138a572bcb634383a47dd7b67e3161d46 100644 (file)
@@ -447,6 +447,7 @@ fn update_precise_first_run() {
       "links": null,
       "manifest_path": "[..]/home/.cargo/registry/src/-[..]/serde-0.2.0/Cargo.toml",
       "metadata": null,
+      "publish": null,
       "name": "serde",
       "readme": null,
       "repository": null,
@@ -494,6 +495,7 @@ fn update_precise_first_run() {
       "links": null,
       "manifest_path": "[..]/foo/Cargo.toml",
       "metadata": null,
+      "publish": null,
       "name": "bar",
       "readme": null,
       "repository": null,