Repository navigation
Add offline license metadata caching support - #273
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds true offline support for git pkgs licenses by reusing the existing SQLite enrichment cache, including allowing stale cache entries in --offline mode while guaranteeing no enrichment API requests are made. It also implements the documented GIT_PKGS_DB override so the metadata DB can be persisted outside .git (e.g., across CI runs), updates docs, and adds regression tests around stale/missing cache behavior and offline drift.
Changes:
- Add
git pkgs licenses --offline(including support for--drift) that uses cached metadata regardless of TTL and errors when required cache entries are missing. - Extend enrichment license lookup timeout from 60s to 5m, and add DB query helpers to fetch cached packages/versions including stale entries.
- Honor
GIT_PKGS_DBfor DB location and document CI caching of the SQLite metadata database.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Document licenses --offline behavior and mention GIT_PKGS_DB for persistence. |
| internal/git/repository.go | Implement GIT_PKGS_DB override (absolute and repo-relative paths). |
| internal/git/repository_test.go | Add coverage for GIT_PKGS_DB override behavior. |
| internal/database/queries.go | Refactor cached package/version queries and add “including stale” variants. |
| docs/internals.md | Document offline license behavior and cache semantics. |
| docs/ci-cd.md | Document caching the SQLite metadata DB via GitHub Actions cache. |
| cmd/licenses.go | Add --offline flag, enforce no network in offline mode, and extend lookup timeouts. |
| cmd/licenses_test.go | Add regression tests for stale cache usage, missing metadata failures, and offline drift 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.
Requesting changes for two reproduced regressions:
-
internal/database/queries.go:1840-1853 — GetCachedPackagesIncludingStale selects funding-, maintainer-, and health-only package rows whose enriched_at is NULL. Scanning that value into a string fails with “converting NULL to string is unsupported”, so licenses --offline returns a raw SQL error instead of the promised cache-miss message. Please exclude rows without enrichment metadata, for example with enriched_at IS NOT NULL, and add coverage for a funding-only row.
-
internal/git/repository.go:81-86 — Custom database paths do not work when their parent directory does not already exist. For example, GIT_PKGS_DB=.cache/pkgs.sqlite3 resolves correctly, but database.Create/OpenOrCreate fails with SQLite error 14 on a clean checkout. Please create the parent directory before opening a new custom database and test actual database creation, not only path calculation.
Both cases were reproduced against this PR revision. The existing CI is green but does not cover them.
|
Updated
|
Closes #272
Summary
Improve offline and reduced-request support for license checks by building on the existing SQLite enrichment cache.
git pkgs licenses --offlinelicenses --driftGIT_PKGS_DBenvironment variableOffline mode intentionally fails when required metadata is missing so license-policy checks cannot silently pass with incomplete data.
Testing
go test ./...go tool golangci-lint run ./...git diff --check