Skip to content

Commit

Permalink
Fallback to non-verified URLs only when a package analysis was not co…
Browse files Browse the repository at this point in the history
…mpleted. (dart-lang#8458)
  • Loading branch information
isoos authored Jan 13, 2025
1 parent dd13f9e commit c1a5322
Show file tree
Hide file tree
Showing 29 changed files with 21 additions and 136 deletions.
37 changes: 21 additions & 16 deletions app/lib/package/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions app/test/frontend/golden/pkg_activity_log_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -469,8 +467,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
4 changes: 0 additions & 4 deletions app/test/frontend/golden/pkg_admin_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -754,8 +752,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
4 changes: 0 additions & 4 deletions app/test/frontend/golden/pkg_changelog_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -340,8 +338,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
4 changes: 0 additions & 4 deletions app/test/frontend/golden/pkg_example_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -337,8 +335,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
4 changes: 0 additions & 4 deletions app/test/frontend/golden/pkg_install_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -363,8 +361,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
4 changes: 0 additions & 4 deletions app/test/frontend/golden/pkg_score_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -425,8 +423,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -425,8 +423,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
4 changes: 0 additions & 4 deletions app/test/frontend/golden/pkg_show_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -340,8 +338,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
8 changes: 0 additions & 8 deletions app/test/frontend/golden/pkg_show_page_discontinued.html
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,8 @@ <h3 class="title">Weekly Downloads</h3>
<h3 class="title pkg-infobox-metadata">Metadata</h3>
<p>pkg is awesome</p>
<p>
<a class="link" href="https://pkg.example.com/" rel="ugc">Homepage</a>
<br/>
<a class="link" href="https://github.com/example/pkg" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/pkg/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/pkg/blob/main/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -329,12 +325,8 @@ <h3 class="title">Weekly Downloads</h3>
<h3 class="title pkg-infobox-metadata">Metadata</h3>
<p>pkg is awesome</p>
<p>
<a class="link" href="https://pkg.example.com/" rel="ugc">Homepage</a>
<br/>
<a class="link" href="https://github.com/example/pkg" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/pkg/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/pkg/blob/main/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
4 changes: 0 additions & 4 deletions app/test/frontend/golden/pkg_show_page_flutter_plugin.html
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/flutter_titanium" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/flutter_titanium/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/flutter_titanium/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -333,8 +331,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/flutter_titanium" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/flutter_titanium/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/flutter_titanium/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
4 changes: 0 additions & 4 deletions app/test/frontend/golden/pkg_show_page_publisher.html
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/neon" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/neon/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/neon/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -334,8 +332,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/neon" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/neon/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/neon/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,8 @@ <h3 class="title">Weekly Downloads</h3>
<h3 class="title pkg-infobox-metadata">Metadata</h3>
<p>pkg is awesome</p>
<p>
<a class="link" href="https://pkg.example.com/" rel="ugc">Homepage</a>
<br/>
<a class="link" href="https://github.com/example/pkg" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/pkg/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/pkg/blob/main/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -320,12 +316,8 @@ <h3 class="title">Weekly Downloads</h3>
<h3 class="title pkg-infobox-metadata">Metadata</h3>
<p>pkg is awesome</p>
<p>
<a class="link" href="https://pkg.example.com/" rel="ugc">Homepage</a>
<br/>
<a class="link" href="https://github.com/example/pkg" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/pkg/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/pkg/blob/main/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
4 changes: 0 additions & 4 deletions app/test/frontend/golden/pkg_show_version_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -334,8 +332,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
4 changes: 0 additions & 4 deletions app/test/frontend/golden/pkg_versions_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -447,8 +445,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
4 changes: 0 additions & 4 deletions app/test/task/testdata/goldens/packages/oxygen.html
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
</p>
<h3 class="title">Topics</h3>
<p>
Expand Down Expand Up @@ -332,8 +330,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
</p>
<h3 class="title">Topics</h3>
<p>
Expand Down
4 changes: 0 additions & 4 deletions app/test/task/testdata/goldens/packages/oxygen/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
</p>
<h3 class="title">Topics</h3>
<p>
Expand Down Expand Up @@ -338,8 +336,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
</p>
<h3 class="title">Topics</h3>
<p>
Expand Down
4 changes: 0 additions & 4 deletions app/test/task/testdata/goldens/packages/oxygen/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
</p>
<h3 class="title">Topics</h3>
<p>
Expand Down Expand Up @@ -333,8 +331,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
</p>
<h3 class="title">Topics</h3>
<p>
Expand Down
4 changes: 0 additions & 4 deletions app/test/task/testdata/goldens/packages/oxygen/install.html
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
</p>
<h3 class="title">Topics</h3>
<p>
Expand Down Expand Up @@ -361,8 +359,6 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
</p>
<h3 class="title">Topics</h3>
<p>
Expand Down
Loading

0 comments on commit c1a5322

Please sign in to comment.