Repository navigation
Add dependency funding info command - #214
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new git pkgs funding command to surface dependency funding links (and optionally highlight missing funding info) using ecosyste.ms metadata, aligning it with existing “extrinsic data” commands like outdated and licenses.
Changes:
- Introduces
git pkgs fundingwith flags--missing,--ecosystem,--commit,--branch, and--format=json. - Implements ecosyste.ms bulk lookup + text/JSON output formatting for funding links.
- Documents the new command and adds unit tests + pager-flag coverage.
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 | Documents the new funding command and adds it to the quick-start command list. |
| docs/internals.md | Updates internals docs to include funding as an extrinsic-data command and notes its bulk lookup approach. |
| cmd/root.go | Registers the new funding subcommand in the root command. |
| cmd/pager_test.go | Ensures the pager flag is accepted for the new funding command. |
| cmd/funding.go | Implements the funding command: dependency selection, bulk lookup, result building, and text/JSON output. |
| cmd/funding_test.go | Adds unit tests for PURL normalization and result building/filtering behavior. |
💡 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.
The bulk lookup keeps the request count low which is good, but this still bypasses the cache and enrichment layers.
fetchFundingPackageData calls ecosystems.NewClient(...).BulkLookup directly. The other metadata commands (outdated, licenses) go through db.GetCachedPackages with the 24h TTL first, then fetch misses via github.com/git-pkgs/enrichment, then write back. Going straight to ecosystems-go means funding re-fetches packages that outdated or licenses already cached, and skips the routing that sends private-registry PURLs to direct registry queries. Please switch to the enrichment client and the cached path; see cmd/outdated.go around line 190.
CachedPackage doesn't currently store funding links so caching this needs a column on the packages table. Happy to discuss whether to add that here or in a separate PR.
Two smaller things:
outputFundingEmptyruns regardless of--format, so--format jsonwith no results prints plain text. The "No lockfile dependencies found." early return has the same problem. JSON output should always be JSON; emit an emptyFundingResultinstead.- The
docs/internals.mdedit changes "fetch and cache this external data" to "fetch this external data, with caching where supported". Please keep the original wording; the fix is to makefundingcache, not to soften the docs.
Thanks, fixed... funding now uses the package cache with a 24h TTL. I added funding_links and funding_synced_at to packages, read cached funding data first, then use the enrichment client for cache misses so package lookup/routing matches outdated/licenses. Since the current enrichment PackageInfo does not expose funding links, the command only reads funding_links from ecosyste.ms for public ecosyste.ms-routed misses, then writes those links back to the package cache. Private/direct-registry PURLs are routed through enrichment and are not sent to ecosyste.ms... i also fixed the JSON empty-result paths to emit an empty FundingResult, restored the internals wording to “fetch and cache this external data” and added tests for cached funding plus empty JSON output... |
andrew
left a comment
There was a problem hiding this comment.
The cache layer and schema work are right: funding_links + funding_synced_at on packages with its own TTL check, GetCachedPackageFunding/SavePackageFundingBatch, and the JSON/docs fixes are all good.
The fetch path is the remaining problem. On a cold cache it calls enrichment.BulkLookup and then ecosystems.NewClient(...).BulkLookup for the same PURLs, because enrichment.PackageInfo doesn't expose funding links. That's two round trips to ecosyste.ms for the same packages, and the first one only contributes pkg.Source and a SavePackageEnrichmentBatch side effect.
Rather than work around it here, we're going to add FundingLinks to enrichment.PackageInfo. The ecosyste.ms bulk response already includes the field so it's just a matter of plumbing it through in that library. Once that's released:
- drop
fetchFundingLinks,fundingLinksFromEcosystems, theecosystems-goimport, and theSavePackageEnrichmentBatchcall fetchFundingPackageDatabecomes: check cache, callenrichment.BulkLookuponce for misses, readpkg.FundingLinks, writeSavePackageFundingBatch
I'll tag a new enrichment release and ping here when it's available.
Two other things for the same push:
fundingLookupTimeout = 60 * time.Secondshould be 5 minutes to matchresolve/add/remove/vulnsSchemaVersion = 10collides with #213 which also bumps to 10; whichever lands second goes to 11. This will also need a rebase onto main now #212 has merged (overlaps inroot.go,pager_test.go,internals.md, README).
1ea5b6a to
7731d94
Compare
thanks, fixed the parts that are available now... i rebased the branch onto main, resolved the freshness/funding conflicts, bumped SchemaVersion to 11 and changed the funding lookup timeout to 5 minutes... i checked github.com/git-pkgs/enrichment and the latest visible release is still v0.2.3; main is also still at that same commit and PackageInfo does not expose FundingLinks yet. I left the fetchFundingLinks path in place for now because dropping it before the enrichment release would make funding unable to read funding links. Once the enrichment release with FundingLinks is available, I’ll switch this to a single enrichment.BulkLookup call and remove the |
|
|
thanks, this is updated now... i bumped I also added coverage for the enrichment-backed path, including the expected empty funding links case.. |
andrew
left a comment
There was a problem hiding this comment.
The switch to enrichment v0.3.0 is exactly what I was after: fetchFundingPackageData is now cache check → one client.BulkLookup for misses → read pkg.FundingLinks → SavePackageFundingBatch, the ecosystems-go import and second-lookup helpers are gone, and the timeout matches the other network commands. The database side (GetCachedPackageFunding batching, SavePackageFundingBatch UPSERT touching only the funding columns) is fine as previously reviewed.
No code changes needed, but #213 has now merged so this needs a rebase onto main. You'll hit conflicts in:
internal/database/database.go: both PRs rewriteSchemaVersion = 9; resolve to11README.md: the network-commands sentence near the top and the quick-start block both changed; keep bothdeprecatedandfundingcmd/pager_test.goandcmd/root.go: both insert adjacent linesdocs/internals.md: the intro paragraph and the Package Enrichment section both changedinternal/database/queries.go: #213 reshapedCachedVersionnext to where this addsCachedPackageFunding
Once rebased and green this is ready to go.
fa9aaf4 to
ba52601
Compare
thanks, rebased onto main and resolved the conflicts... I kept both Tests are green: |
andrew
left a comment
There was a problem hiding this comment.
Rebase landed cleanly and the fetch path now matches what we wanted: cache check, single enrichment.BulkLookup for misses, SavePackageFundingBatch write-back. Thanks for sticking with this through the back and forth.
Closes #24
Summary
git pkgs fundingto show dependencies with published funding links--missingto report dependencies without funding links--ecosystem,--commit,--branchand--format=jsonTesting
go test ./cmd -run 'TestFunding|TestPagerFlagAccepted'go build ./...go test ./...go test -race ./...go tool golangci-lint run ./...git diff --checkgo run . funding --help