From 9af7b897361a032836da828f46ed2a25e4f35863 Mon Sep 17 00:00:00 2001 From: Martin Nonnenmacher Date: Tue, 5 Oct 2021 00:48:41 +0200 Subject: [PATCH] Conan: Try to get the VCS info from the homepage Do not parse the VCS info from the output of "conan info", because this only ever points to the recipe of the package, but not to the source code. Usually this points to the ConanCenter index [1]. Instead, try to parse the VCS info from the homepage URL of the package. This partly addresses #2037. [1] https://github.com/conan-io/conan-center-index Signed-off-by: Martin Nonnenmacher --- .../synthetic/conan-expected-output-py.yml | 12 ++--- .../synthetic/conan-expected-output-txt.yml | 44 +++++++++---------- analyzer/src/main/kotlin/managers/Conan.kt | 11 +++-- 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/analyzer/src/funTest/assets/projects/synthetic/conan-expected-output-py.yml b/analyzer/src/funTest/assets/projects/synthetic/conan-expected-output-py.yml index 7f89d41172fdb..9b64dca50d140 100644 --- a/analyzer/src/funTest/assets/projects/synthetic/conan-expected-output-py.yml +++ b/analyzer/src/funTest/assets/projects/synthetic/conan-expected-output-py.yml @@ -50,12 +50,12 @@ packages: algorithm: "" vcs: type: "Git" - url: "https://github.com/conan-io/conan-center-index" + url: "https://github.com/openssl/openssl.git" revision: "" path: "" vcs_processed: type: "Git" - url: "https://github.com/conan-io/conan-center-index.git" + url: "https://github.com/openssl/openssl.git" revision: "" path: "" - id: "Conan::zlib:1.2.11" @@ -78,12 +78,12 @@ packages: value: "" algorithm: "" vcs: - type: "Git" - url: "https://github.com/conan-io/conan-center-index" + type: "" + url: "" revision: "" path: "" vcs_processed: - type: "Git" - url: "https://github.com/conan-io/conan-center-index.git" + type: "" + url: "" revision: "" path: "" diff --git a/analyzer/src/funTest/assets/projects/synthetic/conan-expected-output-txt.yml b/analyzer/src/funTest/assets/projects/synthetic/conan-expected-output-txt.yml index 8e57464dc902d..81fe940fd80bb 100644 --- a/analyzer/src/funTest/assets/projects/synthetic/conan-expected-output-txt.yml +++ b/analyzer/src/funTest/assets/projects/synthetic/conan-expected-output-txt.yml @@ -50,13 +50,13 @@ packages: value: "" algorithm: "" vcs: - type: "Git" - url: "https://github.com/conan-io/conan-center-index" + type: "" + url: "" revision: "" path: "" vcs_processed: - type: "Git" - url: "https://github.com/conan-io/conan-center-index.git" + type: "" + url: "" revision: "" path: "" - id: "Conan::libiconv:1.16" @@ -80,13 +80,13 @@ packages: value: "" algorithm: "" vcs: - type: "Git" - url: "https://github.com/conan-io/conan-center-index" + type: "" + url: "" revision: "" path: "" vcs_processed: - type: "Git" - url: "https://github.com/conan-io/conan-center-index.git" + type: "" + url: "" revision: "" path: "" - id: "Conan::libxml2:2.9.12" @@ -108,13 +108,13 @@ packages: value: "" algorithm: "" vcs: - type: "Git" - url: "https://github.com/conan-io/conan-center-index" + type: "" + url: "" revision: "" path: "" vcs_processed: - type: "Git" - url: "https://github.com/conan-io/conan-center-index.git" + type: "" + url: "" revision: "" path: "" - id: "Conan::libxslt:1.1.34" @@ -137,13 +137,13 @@ packages: value: "" algorithm: "" vcs: - type: "Git" - url: "https://github.com/conan-io/conan-center-index" + type: "" + url: "" revision: "" path: "" vcs_processed: - type: "Git" - url: "https://github.com/conan-io/conan-center-index.git" + type: "" + url: "" revision: "" path: "" - id: "Conan::openssl:1.1.1l" @@ -167,12 +167,12 @@ packages: algorithm: "" vcs: type: "Git" - url: "https://github.com/conan-io/conan-center-index" + url: "https://github.com/openssl/openssl.git" revision: "" path: "" vcs_processed: type: "Git" - url: "https://github.com/conan-io/conan-center-index.git" + url: "https://github.com/openssl/openssl.git" revision: "" path: "" - id: "Conan::zlib:1.2.11" @@ -195,12 +195,12 @@ packages: value: "" algorithm: "" vcs: - type: "Git" - url: "https://github.com/conan-io/conan-center-index" + type: "" + url: "" revision: "" path: "" vcs_processed: - type: "Git" - url: "https://github.com/conan-io/conan-center-index.git" + type: "" + url: "" revision: "" path: "" diff --git a/analyzer/src/main/kotlin/managers/Conan.kt b/analyzer/src/main/kotlin/managers/Conan.kt index 869e1df2e1b5b..b5191ff94529a 100644 --- a/analyzer/src/main/kotlin/managers/Conan.kt +++ b/analyzer/src/main/kotlin/managers/Conan.kt @@ -263,17 +263,20 @@ class Conan( /** * Return the [Package] parsed from the given [node]. */ - private fun parsePackage(node: JsonNode, workingDir: File) = - Package( + private fun parsePackage(node: JsonNode, workingDir: File): Package { + val homepageUrl = node["homepage"].textValueOrEmpty() + + return Package( id = parsePackageId(node, workingDir), authors = parseAuthors(node), declaredLicenses = parseDeclaredLicenses(node), description = parsePackageField(node, workingDir, "description"), - homepageUrl = node["homepage"].textValueOrEmpty(), + homepageUrl = homepageUrl, binaryArtifact = RemoteArtifact.EMPTY, // TODO: implement me! sourceArtifact = RemoteArtifact.EMPTY, // TODO: implement me! - vcs = parseVcsInfo(node) + vcs = processPackageVcs(VcsInfo.EMPTY, homepageUrl) ) + } /** * Return the value `conan inspect` reports for the given [field].