mirror of
https://github.com/alibaba/open-code-review.git
synced 2026-08-11 09:44:46 +00:00
runPreview, runScanPreview, and delegate's preview each built a throwaway agent via agent.New / scan.NewAgent purely to reach Preview. Both constructors auto-create a session, and session.New opens persistence and buffers a session_start record, so every preview created a JSONL file under the OCR home. Preview never runs or finalizes a review, so that file was left unfinalized and usually empty. Make the exported entry point a package-level Preview(ctx, args) in both internal/agent and internal/scan. It builds only what file selection needs, so there is no session, manifest, or runner to leak. The existing bodies stay as unexported methods, keeping the in-package tests (including scan's regression test that Preview must not mutate a.items). Deleting the file afterwards was rejected: it would still leak on crash and would keep the wrong abstraction. Tests assert at the CLI boundary, with a temporary OCR home, that no session store is created by any of the three preview commands. They also neutralize global git config, which git resolves via XDG_CONFIG_HOME independently of HOME. |
||
|---|---|---|
| .. | ||
| agent.go | ||
| agent_test.go | ||
| batch.go | ||
| batch_test.go | ||
| budget_test.go | ||
| coverage_test.go | ||
| dedup_test.go | ||
| estimate.go | ||
| estimate_test.go | ||
| getters_more_test.go | ||
| getters_test.go | ||
| init_test.go | ||
| preview.go | ||
| provider.go | ||
| provider_more_test.go | ||
| provider_test.go | ||