Repository navigation
Add dependency freshness metrics - #212
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new git pkgs freshness command to measure release-age lag between installed dependency versions and registry-published versions, complementing existing stale/outdated dependency analysis.
Changes:
- Registers and documents the new
freshnesscommand. - Implements freshness metric computation, cache/API version loading, JSON/text output, and limiting.
- Adds command tests covering summary output and JSON limiting.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| README.md | Adds user-facing freshness command examples and explanation. |
| docs/internals.md | Notes freshness as an enrichment-backed command. |
| cmd/root.go | Registers the freshness subcommand. |
| cmd/pager_test.go | Adds freshness to pager flag coverage. |
| cmd/freshness.go | Implements freshness command logic, metrics, enrichment lookup, and output. |
| cmd/freshness_test.go | Adds tests for text and JSON freshness output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
andrew
left a comment
There was a problem hiding this comment.
This is in good shape. It uses the cache layer properly via db.GetCachedVersions / db.SaveVersions and reuses the existing PublishedAt data that outdated already populates, so no schema changes needed.
Two small things before merging:
The 60s context in loadFreshnessVersions wraps the whole sequential loop over missing. On a cold cache with a couple of hundred packages the later fetches will start hitting context deadline exceeded and quietly fall into the unmeasured bucket. Either give each client.GetVersions call its own timeout, or bump the shared one to something like five minutes to match the other enrichment commands.
When there are no resolved dependencies and --format json is set, the command prints No lockfile dependencies found. as plain text. JSON output should always be JSON; emit an empty FreshnessResult instead. Same fix just went in for list in #208.
thanks, fixed.. loadFreshnessVersions now creates a fresh 60s timeout for each GetVersions call, so a cold cache no longer shares one deadline across the whole missing-package loop... i also fixed the no-resolved-dependencies JSON path to emit an empty FreshnessResult instead of plain text and added test coverage for that case... |
andrew
left a comment
There was a problem hiding this comment.
Both points addressed: per-call timeout in the fetch loop and JSON output for the empty case (with a regression test). Thanks.
Closes #20
Summary
Adds a new
git pkgs freshnesscommand for release-age freshness metrics.The command compares installed dependency versions with registry version publish dates and reports:
Options
Supports:
--limit--ecosystem--commit--branch--format jsonNotes
This complements
git pkgs stale:stalemeasures how long a dependency has been unchanged in the repofreshnessmeasures how far installed versions lag behind latest registry releasesTests
go build ./...go test ./...go test -race ./...go tool golangci-lint run ./...git diff --check