Support local reftable git scans#5118
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 634ea476ad
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| if isReftable { | ||
| if err := s.git.ScanRepoPath(ctx, gitDir, s.scanOptions, reporter); err != nil { | ||
| return fmt.Errorf("failed to scan reftable git repository %q: %w", gitDir, err) |
There was a problem hiding this comment.
Report reftable scan failures via ChunkErr
When this path is used through ChunkUnit, returning the ScanRepoPath error here makes SourceManager record it as Fatal (source_manager.go wraps returned chunking errors that way), unlike the non-reftable path below which sends scan failures to reporter.ChunkErr. For a reftable unit with an invalid base/head ref or object error in a multi-unit job, this aborts the scan instead of recording a per-unit chunk error; route this error through reporter.ChunkErr as the normal ScanRepo path does.
Useful? React with 👍 / 👎.
634ea47 to
e2d1f3e
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit d91308c. Configure here.

Description:
Fixes #5019.
This PR adds local Git repository support for repositories using Git's
extensions.refstorage = reftableformat.The failure came from TruffleHog opening local repositories with
go-gitbefore scanning.go-gitrejects therefstoragerepository extension, even though TruffleHog already uses the systemgitCLI for log and diff parsing. The new path detects local reftable repositories from Git config and scans them through the existing CLI-backed parser, avoiding the unsupportedgo-gitopen path.What changed:
extensions.refstorage = reftablefor working tree, bare, and worktree/common-dir layouts--branch,--since-commit, merge-base, and remote URL metadata through system Git on that pathChunkErrpath so one bad unit does not abort a multi-unit scanChecklist:
make test-community)?make lintthis requires golangci-lint)?Additional validation run locally:
CGO_ENABLED=0 go test ./pkg/sources/git -run 'TestRunGitOutputIgnoresSuccessfulStderr|TestChunkUnit_ReftableRepoInvalid|TestIsReftableRepo|TestChunkUnit_ReftableRepo' -count=1CGO_ENABLED=0 go test ./pkg/sources/git -run 'TestGitChunk_LongLine|TestPrepareRepoWithNormalization$|TestPrepareRepoWithNormalizationBare$' -count=1CGO_ENABLED=0 make test-communityCGO_ENABLED=0 make linttrufflehog git --trust-local-git-config --detector-timeout=120s file://.from inside a realgit init --ref-format=reftablerepo scans successfullyNote
Medium Risk
Changes core local git scan routing and adds a parallel metadata/ref-resolution path, but scope is limited to reftable detection and existing CLI parsing is reused; failures are isolated per unit.
Overview
Local directory scans now detect
extensions.refstorage = reftable(working tree, bare, and worktreecommondirlayouts) and skipgo-gitPlainOpen, which cannot open that format.Those repos are scanned through a new
ScanRepoPathpath that still uses the existing CLI-backed log/diff parser. Base/head refs, merge-base, and remote metadata are resolved withgit -Cinstead ofgo-git.runGitOutputreads stdout only so warnings on stderr do not break successful commands.scanDirreports detection and scan failures viaChunkErrso other units can continue. Non-reftable local repos keep the previousgo-gitflow; commit/staged scanning is refactored to sharescanRepoPathwith an injected remote URL.Reviewed by Cursor Bugbot for commit 3aee2ac. Bugbot is set up for automated code reviews on this repo. Configure here.