Visitar URL original
Report packages whose source repo is archived or deleted (GitHub only) by HarnageaGabriel · Pull Request #781 · dotnet-outdated/dotnet-outdated · GitHub
Skip to content

Report packages whose source repo is archived or deleted (GitHub only) - #781

Open
HarnageaGabriel wants to merge 1 commit into
dotnet-outdated:masterfrom
HarnageaGabriel:feature/source-repo-status
Open

HarnageaGabriel wants to merge 1 commit into
dotnet-outdated:masterfrom
HarnageaGabriel:feature/source-repo-status

Conversation

@HarnageaGabriel

Copy link
Copy Markdown

Summary

Reports packages whose source-code repository has been archived or deleted, even when the package itself isn't marked deprecated on NuGet.

Complementary to #181 (deprecated packages) — that covers explicit deprecation metadata; this covers the case where a package's own repo has quietly gone away while the NuGet listing stays untouched.

Scope: GitHub only. Other hosts (GitLab, Bitbucket, etc.) would need their own archived/deleted-detection semantics and API clients — intentionally left out to keep this change focused; the IRepositoryStatusService abstraction leaves room for additional providers later.

How it works

  • NuGetPackageInfoService.GetRepositoryUrl reads the <repository> URL from the package's nuspec — first from the locally-restored global-packages cache (no extra network call for packages already restored), falling back to a metadata download only when not present locally. Falls back to the nuspec's project URL if no repository URL is set.
  • GitHubRepositoryStatusService parses owner/repo out of github.com URLs (including git@github.com: SCP-style and .git suffixes) and checks GET api.github.com/repos/{owner}/{repo}: 404 → NotFound, archived: true → Archived, otherwise Active. Results are cached per repo per run.
  • Resilience: any failure (network error, timeout, rate limit, non-GitHub host) resolves to Unknown rather than throwing — the overall command never fails because of this check. Requests use a 5s timeout.
  • Reporting: a "Repository Status" column appears in the console table only when at least one dependency is Archived or NotFound (kept quiet otherwise), plus new fields in the CSV, Markdown, and JSON output formats.

Known limitation

The GitHub REST API is unauthenticated here (60 requests/hour per IP) — fine for typical project sizes, but large dependency trees run on the free plan may exhaust the quota, in which case remaining checks degrade to Unknown rather than failing.

Test plan

  • dotnet build — clean, no new warnings
  • dotnet test — 217 passed, 0 failed (net8.0 and net9.0)
  • New unit tests for GitHubRepositoryStatusService covering: archived, active, not-found, timeout, non-GitHub URL, network failure
  • Manual smoke test via dotnet run -- test-projects/development-dependencies

Fixes #200

Packages can go stale silently when their source repo is archived or
deleted, even while the NuGet listing itself is untouched — issue dotnet-outdated#181
already covers explicit deprecation metadata, but that leaves this gap
uncovered. Scoped to GitHub only for now: other hosts (GitLab,
Bitbucket, etc.) would need separate archived/deleted detection
semantics and API clients, so this establishes the pattern for one
host rather than guessing at the rest.

Repository URL is read from the installed package's nuspec (reusing
the local global-packages cache when available, falling back to a
download only when necessary) so most lookups need no extra network
round-trip. GitHub API failures, rate limiting, and non-GitHub URLs
are all treated as "Unknown" and never fail the overall command.

Fixes dotnet-outdated#200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Report packages where source repo has been deleted/archived

1 participant