From 8de846081575f46b5416704d38730b8977c879d9 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Wed, 18 Oct 2023 15:32:19 +0200 Subject: [PATCH] feat(cargo): Parse a package's homepage Signed-off-by: Sebastian Schuberth --- .../synthetic/cargo-expected-output.yml | 26 +++++++++---------- .../cargo-subcrate-client-expected-output.yml | 2 +- .../cargo-subcrate-lib-expected-output.yml | 2 +- .../cargo/src/main/kotlin/Cargo.kt | 2 +- .../cargo/src/main/kotlin/CargoMetadata.kt | 3 ++- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/plugins/package-managers/cargo/src/funTest/assets/projects/synthetic/cargo-expected-output.yml b/plugins/package-managers/cargo/src/funTest/assets/projects/synthetic/cargo-expected-output.yml index 7b33e7a9f4335..f287187ec2002 100644 --- a/plugins/package-managers/cargo/src/funTest/assets/projects/synthetic/cargo-expected-output.yml +++ b/plugins/package-managers/cargo/src/funTest/assets/projects/synthetic/cargo-expected-output.yml @@ -169,7 +169,7 @@ packages: declared_licenses_processed: spdx_expression: "Apache-2.0 OR MIT" description: "A macro to generate structures which behave like bitflags.\n" - homepage_url: "" + homepage_url: "https://github.com/bitflags/bitflags" binary_artifact: url: "" hash: @@ -202,7 +202,7 @@ packages: description: "A macro to ergonomically define an item depending on a large number\ \ of #[cfg]\nparameters. Structured like an if-else chain, the first matching\ \ branch is the\nitem that gets emitted.\n" - homepage_url: "" + homepage_url: "https://github.com/alexcrichton/cfg-if" binary_artifact: url: "" hash: @@ -233,7 +233,7 @@ packages: spdx_expression: "BSD-2-Clause" description: "Low level interface to CloudABI. Contains all syscalls and related\ \ types." - homepage_url: "" + homepage_url: "https://nuxi.nl/cloudabi/" binary_artifact: url: "" hash: @@ -294,7 +294,7 @@ packages: declared_licenses_processed: spdx_expression: "Apache-2.0 OR MIT" description: "Raw FFI bindings to platform libraries like libc.\n" - homepage_url: "" + homepage_url: "https://github.com/rust-lang/libc" binary_artifact: url: "" hash: @@ -326,7 +326,7 @@ packages: declared_licenses_processed: spdx_expression: "Apache-2.0 OR MIT" description: "Random number generators and other randomness functionality.\n" - homepage_url: "" + homepage_url: "https://crates.io/crates/rand" binary_artifact: url: "" hash: @@ -358,7 +358,7 @@ packages: declared_licenses_processed: spdx_expression: "Apache-2.0 OR MIT" description: "ChaCha random number generator\n" - homepage_url: "" + homepage_url: "https://crates.io/crates/rand_chacha" binary_artifact: url: "" hash: @@ -390,7 +390,7 @@ packages: declared_licenses_processed: spdx_expression: "Apache-2.0 OR MIT" description: "Core random number generator traits and tools for implementation.\n" - homepage_url: "" + homepage_url: "https://crates.io/crates/rand_core" binary_artifact: url: "" hash: @@ -422,7 +422,7 @@ packages: declared_licenses_processed: spdx_expression: "Apache-2.0 OR MIT" description: "Core random number generator traits and tools for implementation.\n" - homepage_url: "" + homepage_url: "https://crates.io/crates/rand_core" binary_artifact: url: "" hash: @@ -453,7 +453,7 @@ packages: declared_licenses_processed: spdx_expression: "Apache-2.0 OR MIT" description: "HC128 random number generator\n" - homepage_url: "" + homepage_url: "https://crates.io/crates/rand_hc" binary_artifact: url: "" hash: @@ -485,7 +485,7 @@ packages: declared_licenses_processed: spdx_expression: "Apache-2.0 OR MIT" description: "ISAAC random number generator\n" - homepage_url: "" + homepage_url: "https://crates.io/crates/rand_isaac" binary_artifact: url: "" hash: @@ -546,7 +546,7 @@ packages: declared_licenses_processed: spdx_expression: "Apache-2.0 OR MIT" description: "OS backed Random Number Generator" - homepage_url: "" + homepage_url: "https://crates.io/crates/rand_os" binary_artifact: url: "" hash: @@ -577,7 +577,7 @@ packages: declared_licenses_processed: spdx_expression: "Apache-2.0 OR MIT" description: "Selected PCG random number generators\n" - homepage_url: "" + homepage_url: "https://crates.io/crates/rand_pcg" binary_artifact: url: "" hash: @@ -609,7 +609,7 @@ packages: declared_licenses_processed: spdx_expression: "Apache-2.0 OR MIT" description: "Xorshift random number generator\n" - homepage_url: "" + homepage_url: "https://crates.io/crates/rand_xorshift" binary_artifact: url: "" hash: diff --git a/plugins/package-managers/cargo/src/funTest/assets/projects/synthetic/cargo-subcrate-client-expected-output.yml b/plugins/package-managers/cargo/src/funTest/assets/projects/synthetic/cargo-subcrate-client-expected-output.yml index 3799a702da03b..7203ff969bb36 100644 --- a/plugins/package-managers/cargo/src/funTest/assets/projects/synthetic/cargo-subcrate-client-expected-output.yml +++ b/plugins/package-managers/cargo/src/funTest/assets/projects/synthetic/cargo-subcrate-client-expected-output.yml @@ -38,7 +38,7 @@ packages: description: "A macro to ergonomically define an item depending on a large number\ \ of #[cfg]\nparameters. Structured like an if-else chain, the first matching\ \ branch is the\nitem that gets emitted.\n" - homepage_url: "" + homepage_url: "https://github.com/alexcrichton/cfg-if" binary_artifact: url: "" hash: diff --git a/plugins/package-managers/cargo/src/funTest/assets/projects/synthetic/cargo-subcrate-lib-expected-output.yml b/plugins/package-managers/cargo/src/funTest/assets/projects/synthetic/cargo-subcrate-lib-expected-output.yml index c4e75364f217e..9d0f46564f650 100644 --- a/plugins/package-managers/cargo/src/funTest/assets/projects/synthetic/cargo-subcrate-lib-expected-output.yml +++ b/plugins/package-managers/cargo/src/funTest/assets/projects/synthetic/cargo-subcrate-lib-expected-output.yml @@ -45,7 +45,7 @@ packages: description: "A macro to ergonomically define an item depending on a large number\ \ of #[cfg]\nparameters. Structured like an if-else chain, the first matching\ \ branch is the\nitem that gets emitted.\n" - homepage_url: "" + homepage_url: "https://github.com/alexcrichton/cfg-if" binary_artifact: url: "" hash: diff --git a/plugins/package-managers/cargo/src/main/kotlin/Cargo.kt b/plugins/package-managers/cargo/src/main/kotlin/Cargo.kt index 9fc5739a688c2..04b8441e7fe58 100644 --- a/plugins/package-managers/cargo/src/main/kotlin/Cargo.kt +++ b/plugins/package-managers/cargo/src/main/kotlin/Cargo.kt @@ -270,7 +270,7 @@ private fun parsePackage(pkg: CargoMetadata.Package, hashes: Map description = pkg.description.orEmpty(), binaryArtifact = RemoteArtifact.EMPTY, sourceArtifact = parseSourceArtifact(pkg, hashes).orEmpty(), - homepageUrl = "", + homepageUrl = pkg.homepage.orEmpty(), vcs = VcsHost.parseUrl(pkg.repository.orEmpty()) ) } diff --git a/plugins/package-managers/cargo/src/main/kotlin/CargoMetadata.kt b/plugins/package-managers/cargo/src/main/kotlin/CargoMetadata.kt index 6c027913cb633..e43986d6bb9ac 100644 --- a/plugins/package-managers/cargo/src/main/kotlin/CargoMetadata.kt +++ b/plugins/package-managers/cargo/src/main/kotlin/CargoMetadata.kt @@ -42,7 +42,8 @@ internal data class CargoMetadata( val source: String?, val dependencies: List, val authors: List, - val repository: String? + val repository: String?, + val homepage: String? ) @JsonIgnoreProperties(ignoreUnknown = true)