From c1a5322be68996b07ebe49ea1dfb48ef710518a4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Istv=C3=A1n=20So=C3=B3s?=
Date: Mon, 13 Jan 2025 15:12:10 +0100
Subject: [PATCH] Fallback to non-verified URLs only when a package analysis
was not completed. (#8458)
---
app/lib/package/models.dart | 37 +++++++++++--------
.../golden/pkg_activity_log_page.html | 4 --
app/test/frontend/golden/pkg_admin_page.html | 4 --
.../frontend/golden/pkg_changelog_page.html | 4 --
.../frontend/golden/pkg_example_page.html | 4 --
.../frontend/golden/pkg_install_page.html | 4 --
app/test/frontend/golden/pkg_score_page.html | 4 --
.../pkg_score_page_with_downloads_chart.html | 4 --
app/test/frontend/golden/pkg_show_page.html | 4 --
.../golden/pkg_show_page_discontinued.html | 8 ----
.../golden/pkg_show_page_flutter_plugin.html | 4 --
.../golden/pkg_show_page_publisher.html | 4 --
..._page_retracted_non_retracted_version.html | 8 ----
.../golden/pkg_show_version_page.html | 4 --
.../frontend/golden/pkg_versions_page.html | 4 --
.../testdata/goldens/packages/oxygen.html | 4 --
.../goldens/packages/oxygen/changelog.html | 4 --
.../goldens/packages/oxygen/example.html | 4 --
.../goldens/packages/oxygen/install.html | 4 --
.../goldens/packages/oxygen/license.html | 4 --
.../goldens/packages/oxygen/score.html | 4 --
.../goldens/packages/oxygen/versions.html | 4 --
.../packages/oxygen/versions/1.0.0.html | 4 --
.../oxygen/versions/1.0.0/changelog.html | 4 --
.../oxygen/versions/1.0.0/example.html | 4 --
.../oxygen/versions/1.0.0/install.html | 4 --
.../oxygen/versions/1.0.0/license.html | 4 --
.../packages/oxygen/versions/1.0.0/score.html | 4 --
.../packages/oxygen/versions/2.0.0.html | 4 --
29 files changed, 21 insertions(+), 136 deletions(-)
diff --git a/app/lib/package/models.dart b/app/lib/package/models.dart
index 0e715dfb9..814647438 100644
--- a/app/lib/package/models.dart
+++ b/app/lib/package/models.dart
@@ -1131,28 +1131,33 @@ class PackagePageData {
bool get isLatestStable => version.version == package.latestVersion;
late final packageLinks = () {
- // start with the URLs from pubspec.yaml
+ // If the repository failed the verification tests, we are not displaying
+ // any links.
+ final result = scoreCard.panaReport?.result;
+ final repositoryStatus = result?.repositoryStatus;
+ if (repositoryStatus == RepositoryStatus.failed) {
+ return PackageLinks._();
+ }
+
+ // If the analysis completed, return the URLs from it.
+ if (result != null) {
+ return PackageLinks._(
+ homepageUrl: result.homepageUrl,
+ repositoryUrl: result.repositoryUrl,
+ issueTrackerUrl: result.issueTrackerUrl,
+ documentationUrl: result.documentationUrl,
+ contributingUrl: result.contributingUrl,
+ );
+ }
+
+ // Fallback: if the analysis did not complete yet, display inferred URLs from pubspec.yaml
final pubspec = version.pubspec!;
- final inferred = PackageLinks.infer(
+ return PackageLinks.infer(
homepageUrl: pubspec.homepage,
documentationUrl: pubspec.documentation,
repositoryUrl: pubspec.repository,
issueTrackerUrl: pubspec.issueTracker,
);
-
- // Use verified URLs when they are available.
- final result = scoreCard.panaReport?.result;
- if (result == null) {
- return inferred;
- }
-
- return PackageLinks._(
- homepageUrl: result.homepageUrl ?? inferred.homepageUrl,
- repositoryUrl: result.repositoryUrl ?? inferred.repositoryUrl,
- issueTrackerUrl: result.issueTrackerUrl ?? inferred.issueTrackerUrl,
- documentationUrl: result.documentationUrl ?? inferred.documentationUrl,
- contributingUrl: result.contributingUrl ?? inferred.contributingUrl,
- );
}();
/// The URL resolver using a verified repository
diff --git a/app/test/frontend/golden/pkg_activity_log_page.html b/app/test/frontend/golden/pkg_activity_log_page.html
index b5c8f3bbe..7546028f6 100644
--- a/app/test/frontend/golden/pkg_activity_log_page.html
+++ b/app/test/frontend/golden/pkg_activity_log_page.html
@@ -391,8 +391,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
@@ -469,8 +467,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
diff --git a/app/test/frontend/golden/pkg_admin_page.html b/app/test/frontend/golden/pkg_admin_page.html
index 8cb795dde..e4b0eecfc 100644
--- a/app/test/frontend/golden/pkg_admin_page.html
+++ b/app/test/frontend/golden/pkg_admin_page.html
@@ -676,8 +676,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
@@ -754,8 +752,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
diff --git a/app/test/frontend/golden/pkg_changelog_page.html b/app/test/frontend/golden/pkg_changelog_page.html
index 789fe43ba..c1731011b 100644
--- a/app/test/frontend/golden/pkg_changelog_page.html
+++ b/app/test/frontend/golden/pkg_changelog_page.html
@@ -261,8 +261,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
@@ -340,8 +338,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
diff --git a/app/test/frontend/golden/pkg_example_page.html b/app/test/frontend/golden/pkg_example_page.html
index 6def196bd..81eabba50 100644
--- a/app/test/frontend/golden/pkg_example_page.html
+++ b/app/test/frontend/golden/pkg_example_page.html
@@ -258,8 +258,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
@@ -337,8 +335,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
diff --git a/app/test/frontend/golden/pkg_install_page.html b/app/test/frontend/golden/pkg_install_page.html
index d9578ef82..106438baa 100644
--- a/app/test/frontend/golden/pkg_install_page.html
+++ b/app/test/frontend/golden/pkg_install_page.html
@@ -284,8 +284,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
@@ -363,8 +361,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
diff --git a/app/test/frontend/golden/pkg_score_page.html b/app/test/frontend/golden/pkg_score_page.html
index 23fc48a92..a57490b8b 100644
--- a/app/test/frontend/golden/pkg_score_page.html
+++ b/app/test/frontend/golden/pkg_score_page.html
@@ -346,8 +346,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
@@ -425,8 +423,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
diff --git a/app/test/frontend/golden/pkg_score_page_with_downloads_chart.html b/app/test/frontend/golden/pkg_score_page_with_downloads_chart.html
index 23fc48a92..a57490b8b 100644
--- a/app/test/frontend/golden/pkg_score_page_with_downloads_chart.html
+++ b/app/test/frontend/golden/pkg_score_page_with_downloads_chart.html
@@ -346,8 +346,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
@@ -425,8 +423,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
diff --git a/app/test/frontend/golden/pkg_show_page.html b/app/test/frontend/golden/pkg_show_page.html
index 576cb4200..f57c69d33 100644
--- a/app/test/frontend/golden/pkg_show_page.html
+++ b/app/test/frontend/golden/pkg_show_page.html
@@ -261,8 +261,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
@@ -340,8 +338,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
diff --git a/app/test/frontend/golden/pkg_show_page_discontinued.html b/app/test/frontend/golden/pkg_show_page_discontinued.html
index d8e814a66..6f72ac6b3 100644
--- a/app/test/frontend/golden/pkg_show_page_discontinued.html
+++ b/app/test/frontend/golden/pkg_show_page_discontinued.html
@@ -250,12 +250,8 @@ Weekly Downloads
pkg is awesome
- Homepage
-
Repository (GitHub)
- View/report issues
-
Contributing
@@ -329,12 +325,8 @@ Weekly Downloads
pkg is awesome
- Homepage
-
Repository (GitHub)
- View/report issues
-
Contributing
diff --git a/app/test/frontend/golden/pkg_show_page_flutter_plugin.html b/app/test/frontend/golden/pkg_show_page_flutter_plugin.html
index 5fc296b47..57feb55da 100644
--- a/app/test/frontend/golden/pkg_show_page_flutter_plugin.html
+++ b/app/test/frontend/golden/pkg_show_page_flutter_plugin.html
@@ -250,8 +250,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
@@ -333,8 +331,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
diff --git a/app/test/frontend/golden/pkg_show_page_publisher.html b/app/test/frontend/golden/pkg_show_page_publisher.html
index c4a9ce5b7..b4d8db7ca 100644
--- a/app/test/frontend/golden/pkg_show_page_publisher.html
+++ b/app/test/frontend/golden/pkg_show_page_publisher.html
@@ -252,8 +252,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
@@ -334,8 +332,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
diff --git a/app/test/frontend/golden/pkg_show_page_retracted_non_retracted_version.html b/app/test/frontend/golden/pkg_show_page_retracted_non_retracted_version.html
index 90ec9e9a3..9f0309217 100644
--- a/app/test/frontend/golden/pkg_show_page_retracted_non_retracted_version.html
+++ b/app/test/frontend/golden/pkg_show_page_retracted_non_retracted_version.html
@@ -241,12 +241,8 @@ Weekly Downloads
pkg is awesome
- Homepage
-
Repository (GitHub)
- View/report issues
-
Contributing
@@ -320,12 +316,8 @@ Weekly Downloads
pkg is awesome
- Homepage
-
Repository (GitHub)
- View/report issues
-
Contributing
diff --git a/app/test/frontend/golden/pkg_show_version_page.html b/app/test/frontend/golden/pkg_show_version_page.html
index 0d147baa5..b58f863e0 100644
--- a/app/test/frontend/golden/pkg_show_version_page.html
+++ b/app/test/frontend/golden/pkg_show_version_page.html
@@ -255,8 +255,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
@@ -334,8 +332,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
diff --git a/app/test/frontend/golden/pkg_versions_page.html b/app/test/frontend/golden/pkg_versions_page.html
index a92e00f99..2b37612be 100644
--- a/app/test/frontend/golden/pkg_versions_page.html
+++ b/app/test/frontend/golden/pkg_versions_page.html
@@ -368,8 +368,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
@@ -447,8 +445,6 @@
Repository (GitHub)
- View/report issues
-
Contributing
diff --git a/app/test/task/testdata/goldens/packages/oxygen.html b/app/test/task/testdata/goldens/packages/oxygen.html
index 2e2793bbd..9bcc32394 100644
--- a/app/test/task/testdata/goldens/packages/oxygen.html
+++ b/app/test/task/testdata/goldens/packages/oxygen.html
@@ -251,8 +251,6 @@
Repository (GitHub)
- View/report issues
-
Topics
@@ -332,8 +330,6 @@
Repository (GitHub)
- View/report issues
-
Topics
diff --git a/app/test/task/testdata/goldens/packages/oxygen/changelog.html b/app/test/task/testdata/goldens/packages/oxygen/changelog.html
index 23b8da0c9..16fb7fdbb 100644
--- a/app/test/task/testdata/goldens/packages/oxygen/changelog.html
+++ b/app/test/task/testdata/goldens/packages/oxygen/changelog.html
@@ -257,8 +257,6 @@
Repository (GitHub)
- View/report issues
-
Topics
@@ -338,8 +336,6 @@
Repository (GitHub)
- View/report issues
-
Topics
diff --git a/app/test/task/testdata/goldens/packages/oxygen/example.html b/app/test/task/testdata/goldens/packages/oxygen/example.html
index 806bb5bc7..2c10d6d6e 100644
--- a/app/test/task/testdata/goldens/packages/oxygen/example.html
+++ b/app/test/task/testdata/goldens/packages/oxygen/example.html
@@ -252,8 +252,6 @@
Repository (GitHub)
- View/report issues
-
Topics
@@ -333,8 +331,6 @@
Repository (GitHub)
- View/report issues
-
Topics
diff --git a/app/test/task/testdata/goldens/packages/oxygen/install.html b/app/test/task/testdata/goldens/packages/oxygen/install.html
index 8b04a4974..661b6add1 100644
--- a/app/test/task/testdata/goldens/packages/oxygen/install.html
+++ b/app/test/task/testdata/goldens/packages/oxygen/install.html
@@ -280,8 +280,6 @@
Repository (GitHub)
- View/report issues
-
Topics
@@ -361,8 +359,6 @@
Repository (GitHub)
- View/report issues
-
Topics
diff --git a/app/test/task/testdata/goldens/packages/oxygen/license.html b/app/test/task/testdata/goldens/packages/oxygen/license.html
index 9b2932c63..e5a5d3144 100644
--- a/app/test/task/testdata/goldens/packages/oxygen/license.html
+++ b/app/test/task/testdata/goldens/packages/oxygen/license.html
@@ -253,8 +253,6 @@
Repository (GitHub)
- View/report issues
-
Topics
@@ -334,8 +332,6 @@
Repository (GitHub)
- View/report issues
-
Topics
diff --git a/app/test/task/testdata/goldens/packages/oxygen/score.html b/app/test/task/testdata/goldens/packages/oxygen/score.html
index 8846cbc89..6ba43b1b6 100644
--- a/app/test/task/testdata/goldens/packages/oxygen/score.html
+++ b/app/test/task/testdata/goldens/packages/oxygen/score.html
@@ -561,8 +561,6 @@
Repository (GitHub)
- View/report issues
-
Topics
@@ -642,8 +640,6 @@
Repository (GitHub)
- View/report issues
-
Topics
diff --git a/app/test/task/testdata/goldens/packages/oxygen/versions.html b/app/test/task/testdata/goldens/packages/oxygen/versions.html
index 07aa34c37..13315ea2c 100644
--- a/app/test/task/testdata/goldens/packages/oxygen/versions.html
+++ b/app/test/task/testdata/goldens/packages/oxygen/versions.html
@@ -313,8 +313,6 @@
Repository (GitHub)
- View/report issues
-
Topics
@@ -394,8 +392,6 @@
Repository (GitHub)
- View/report issues
-
Topics
diff --git a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0.html b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0.html
index 3008e612f..c563ebc34 100644
--- a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0.html
+++ b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0.html
@@ -255,8 +255,6 @@
Repository (GitHub)
- View/report issues
-
Topics
@@ -336,8 +334,6 @@
Repository (GitHub)
- View/report issues
-
Topics
diff --git a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/changelog.html b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/changelog.html
index 9511613db..5146f6c14 100644
--- a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/changelog.html
+++ b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/changelog.html
@@ -261,8 +261,6 @@
Repository (GitHub)
- View/report issues
-
Topics
@@ -342,8 +340,6 @@
Repository (GitHub)
- View/report issues
-
Topics
diff --git a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/example.html b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/example.html
index 202895a35..de044ad22 100644
--- a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/example.html
+++ b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/example.html
@@ -256,8 +256,6 @@
Repository (GitHub)
- View/report issues
-
Topics
@@ -337,8 +335,6 @@
Repository (GitHub)
- View/report issues
-
Topics
diff --git a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/install.html b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/install.html
index 1029cc1fc..96f7d8da9 100644
--- a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/install.html
+++ b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/install.html
@@ -284,8 +284,6 @@
Repository (GitHub)
- View/report issues
-
Topics
@@ -365,8 +363,6 @@
Repository (GitHub)
- View/report issues
-
Topics
diff --git a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/license.html b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/license.html
index d7ebe6c83..d134f4e7c 100644
--- a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/license.html
+++ b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/license.html
@@ -257,8 +257,6 @@
Repository (GitHub)
- View/report issues
-
Topics
@@ -338,8 +336,6 @@
Repository (GitHub)
- View/report issues
-
Topics
diff --git a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/score.html b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/score.html
index 2efeaea0b..d63aef019 100644
--- a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/score.html
+++ b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/score.html
@@ -565,8 +565,6 @@
Repository (GitHub)
- View/report issues
-
Topics
@@ -646,8 +644,6 @@
Repository (GitHub)
- View/report issues
-
Topics
diff --git a/app/test/task/testdata/goldens/packages/oxygen/versions/2.0.0.html b/app/test/task/testdata/goldens/packages/oxygen/versions/2.0.0.html
index 2e2793bbd..9bcc32394 100644
--- a/app/test/task/testdata/goldens/packages/oxygen/versions/2.0.0.html
+++ b/app/test/task/testdata/goldens/packages/oxygen/versions/2.0.0.html
@@ -251,8 +251,6 @@
Repository (GitHub)
- View/report issues
-
Topics
@@ -332,8 +330,6 @@
Repository (GitHub)
- View/report issues
-
Topics