Skip to content

Add dependency funding info command - #214

Merged
andrew merged 5 commits into
git-pkgs:mainfrom
abhinavgautam01:feature/funding-info-24
Jun 2, 2026
Merged

andrew merged 5 commits into
git-pkgs:mainfrom
abhinavgautam01:feature/funding-info-24

Conversation

@abhinavgautam01

Copy link
Copy Markdown
Contributor

Closes #24

Summary

  • Add git pkgs funding to show dependencies with published funding links
  • Add --missing to report dependencies without funding links
  • Support --ecosystem, --commit, --branch and --format=json
  • Document the new command in README and internals docs

Testing

  • go test ./cmd -run 'TestFunding|TestPagerFlagAccepted'
  • go build ./...
  • go test ./...
  • go test -race ./...
  • go tool golangci-lint run ./...
  • git diff --check
  • go run . funding --help

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 funding with 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.

Comment thread cmd/funding.go Resolved

@andrew andrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  • outputFundingEmpty runs regardless of --format, so --format json with no results prints plain text. The "No lockfile dependencies found." early return has the same problem. JSON output should always be JSON; emit an empty FundingResult instead.
  • The docs/internals.md edit 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 make funding cache, not to soften the docs.

@abhinavgautam01

Copy link
Copy Markdown
Contributor Author

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:

  • outputFundingEmpty runs regardless of --format, so --format json with no results prints plain text. The "No lockfile dependencies found." early return has the same problem. JSON output should always be JSON; emit an empty FundingResult instead.
  • The docs/internals.md edit 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 make funding cache, 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 andrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, the ecosystems-go import, and the SavePackageEnrichmentBatch call
  • fetchFundingPackageData becomes: check cache, call enrichment.BulkLookup once for misses, read pkg.FundingLinks, write SavePackageFundingBatch

I'll tag a new enrichment release and ping here when it's available.

Two other things for the same push:

  • fundingLookupTimeout = 60 * time.Second should be 5 minutes to match resolve/add/remove/vulns
  • SchemaVersion = 10 collides 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 in root.go, pager_test.go, internals.md, README).

@abhinavgautam01

Copy link
Copy Markdown
Contributor Author

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, the ecosystems-go import, and the SavePackageEnrichmentBatch call
  • fetchFundingPackageData becomes: check cache, call enrichment.BulkLookup once for misses, read pkg.FundingLinks, write SavePackageFundingBatch

I'll tag a new enrichment release and ping here when it's available.

Two other things for the same push:

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
direct ecosystems-go fetch path....

@abhinavgautam01
abhinavgautam01 requested a review from andrew May 28, 2026 14:44
@andrew

andrew commented May 29, 2026

Copy link
Copy Markdown
Contributor

enrichment v0.3.0 is tagged with PackageInfo.FundingLinks []string (git-pkgs/enrichment#26), so this can be unblocked now.

  • bump github.com/git-pkgs/enrichment to v0.3.0 in go.mod
  • drop fetchFundingLinks, fundingLinksFromEcosystems, the ecosystems-go import, and the SavePackageEnrichmentBatch side-effect call
  • fetchFundingPackageData becomes: cache check → one client.BulkLookup(ctx, misses) → read pkg.FundingLinks → SavePackageFundingBatch

FundingLinks is only populated by the ecosyste.ms backend; the registries/deps.dev backends leave it empty, which is fine since registries don't expose funding metadata anyway.

@abhinavgautam01

Copy link
Copy Markdown
Contributor Author

enrichment v0.3.0 is tagged with PackageInfo.FundingLinks []string (git-pkgs/enrichment#26), so this can be unblocked now.

  • bump github.com/git-pkgs/enrichment to v0.3.0 in go.mod
  • drop fetchFundingLinks, fundingLinksFromEcosystems, the ecosystems-go import, and the SavePackageEnrichmentBatch side-effect call
  • fetchFundingPackageData becomes: cache check → one client.BulkLookup(ctx, misses) → read pkg.FundingLinks → SavePackageFundingBatch

FundingLinks is only populated by the ecosyste.ms backend; the registries/deps.dev backends leave it empty, which is fine since registries don't expose funding metadata anyway.

thanks, this is updated now...

i bumped github.com/git-pkgs/enrichment to v0.3.0 and changed the funding miss path to use a single enrichment BulkLookup, reading pkg.FundingLinks directly. i removed the extra ecosystems-go lookup helpers and dropped the SavePackageEnrichmentBatch side effect, so the command now only writes funding data through SavePackageFundingBatch...

I also added coverage for the enrichment-backed path, including the expected empty funding links case..

@andrew andrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 rewrite SchemaVersion = 9; resolve to 11
  • README.md: the network-commands sentence near the top and the quick-start block both changed; keep both deprecated and funding
  • cmd/pager_test.go and cmd/root.go: both insert adjacent lines
  • docs/internals.md: the intro paragraph and the Package Enrichment section both changed
  • internal/database/queries.go: #213 reshaped CachedVersion next to where this adds CachedPackageFunding

Once rebased and green this is ready to go.

@abhinavgautam01
abhinavgautam01 force-pushed the feature/funding-info-24 branch from fa9aaf4 to ba52601 Compare May 31, 2026 08:31
@abhinavgautam01

Copy link
Copy Markdown
Contributor Author

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 rewrite SchemaVersion = 9; resolve to 11
  • README.md: the network-commands sentence near the top and the quick-start block both changed; keep both deprecated and funding
  • cmd/pager_test.go and cmd/root.go: both insert adjacent lines
  • docs/internals.md: the intro paragraph and the Package Enrichment section both changed
  • internal/database/queries.go: Add deprecated dependency warnings #213 reshaped CachedVersion next to where this adds CachedPackageFunding

Once rebased and green this is ready to go.

thanks, rebased onto main and resolved the conflicts...

I kept both deprecated and funding in the README quick-start/docs, kept both command registrations and pager test entries, resolved the package-enrichment docs to mention both funding and deprecated cache behavior and resolved the schema version to 11. The merged CachedVersion shape from #213 is preserved alongside the funding cache helpers..

Tests are green: go test ./cmd -run 'Funding|Pager', go test ./internal/database, go test ./..., and git diff --check.

@abhinavgautam01
abhinavgautam01 requested a review from andrew May 31, 2026 08:36

@andrew andrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@andrew
andrew merged commit 9a7da00 into git-pkgs:main Jun 2, 2026
4 checks passed
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.

Funding info

3 participants