Blob Blame History Raw
From ab493a17d0eb5d148f4bc504408c7071c12a438b Mon Sep 17 00:00:00 2001
From: Robert Vally <rvally@gmail.com>
Date: Thu, 2 Feb 2017 15:59:34 +0800
Subject: [PATCH 1/2] Metadata response now also contains package description.

---
 src/cargo/core/package.rs | 3 +++
 tests/metadata.rs         | 9 +++++++++
 2 files changed, 12 insertions(+)

diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs
index 58135fda..6b4cd283 100644
--- a/src/cargo/core/package.rs
+++ b/src/cargo/core/package.rs
@@ -31,6 +31,7 @@ struct SerializedPackage<'a> {
     id: &'a PackageId,
     license: Option<&'a str>,
     license_file: Option<&'a str>,
+    description: Option<&'a str>,
     source: &'a SourceId,
     dependencies: &'a [Dependency],
     targets: &'a [Target],
@@ -45,6 +46,7 @@ impl Encodable for Package {
         let manmeta = self.manifest.metadata();
         let license = manmeta.license.as_ref().map(String::as_ref);
         let license_file = manmeta.license_file.as_ref().map(String::as_ref);
+        let description = manmeta.description.as_ref().map(String::as_ref);
 
         SerializedPackage {
             name: &package_id.name(),
@@ -52,6 +54,7 @@ impl Encodable for Package {
             id: package_id,
             license: license,
             license_file: license_file,
+            description: description,
             source: summary.source_id(),
             dependencies: summary.dependencies(),
             targets: &self.manifest.targets(),
diff --git a/tests/metadata.rs b/tests/metadata.rs
index e65beb7e..349de9fc 100644
--- a/tests/metadata.rs
+++ b/tests/metadata.rs
@@ -22,6 +22,7 @@ fn cargo_metadata_simple() {
                 "dependencies": [],
                 "license": null,
                 "license_file": null,
+                "description": null,
                 "targets": [
                     {
                         "kind": [
@@ -86,6 +87,7 @@ fn cargo_metadata_with_deps_and_version() {
                 "source": "registry+[..]",
                 "license": null,
                 "license_file": null,
+                "description": null,
                 "targets": [
                     {
                         "kind": [
@@ -117,6 +119,7 @@ fn cargo_metadata_with_deps_and_version() {
                 "source": "registry+[..]",
                 "license": null,
                 "license_file": null,
+                "description": null,
                 "targets": [
                     {
                         "kind": [
@@ -148,6 +151,7 @@ fn cargo_metadata_with_deps_and_version() {
                 "source": null,
                 "license": "MIT",
                 "license_file": null,
+                "description": "foo",
                 "targets": [
                     {
                         "kind": [
@@ -210,6 +214,7 @@ fn workspace_metadata() {
                 "dependencies": [],
                 "license": null,
                 "license_file": null,
+                "description": null,
                 "targets": [
                     {
                         "kind": [ "lib" ],
@@ -228,6 +233,7 @@ fn workspace_metadata() {
                 "dependencies": [],
                 "license": null,
                 "license_file": null,
+                "description": null,
                 "targets": [
                     {
                         "kind": [ "lib" ],
@@ -281,6 +287,7 @@ fn workspace_metadata_no_deps() {
                 "dependencies": [],
                 "license": null,
                 "license_file": null,
+                "description": null,
                 "targets": [
                     {
                         "kind": [ "lib" ],
@@ -299,6 +306,7 @@ fn workspace_metadata_no_deps() {
                 "dependencies": [],
                 "license": null,
                 "license_file": null,
+                "description": null,
                 "targets": [
                     {
                         "kind": [ "lib" ],
@@ -340,6 +348,7 @@ const MANIFEST_OUTPUT: &'static str=
         "dependencies":[],
         "license": null,
         "license_file": null,
+        "description": null,
         "targets":[{
             "kind":["bin"],
             "name":"foo",
-- 
2.11.1