open-code-review/internal/tool
chethanuk c973e581ec
Some checks are pending
CI / test (push) Waiting to run
fix(tool): resolve file_read paths against git top-level in monorepos (#309)
* fix(tool): resolve file_read paths against git top-level in monorepos

ocr review from a monorepo subdirectory failed with "file not found" (#287):
git reports diff and `git show HEAD:<path>` paths relative to the repo root,
but RepoDir was scoped to the invocation subdirectory, producing a double
prefix. resolveWorkingDir now anchors RepoDir at `git rev-parse
--show-toplevel` on the review path (requireGit=true); scan keeps the CWD so
its `git ls-files` walk stays scoped.

The top-level lookup uses a stdout-only git helper so stderr notices can't
pollute the path, and fails loudly if --show-toplevel errors or is empty
(e.g. a bare repo) instead of silently reusing the subdirectory. Adds
regression tests for the subdir hoist, the scan-path scoping, git-show
resolution of root-relative paths, and the bare-repo failure.

* docs(rules): document repo-root rule.json resolution in monorepos

Since #287 anchored RepoDir at the git top-level, ocr review from a
monorepo subdirectory loads the repo-root .opencodereview/rule.json
rather than a subdir-local one. Call out this user-visible behavior at
loadProjectRule so the scope change isn't a surprise (review feedback).
2026-07-07 20:06:28 +08:00
..
code_comment.go feat(review): add structured category and severity to findings (#311) 2026-07-07 13:08:41 +08:00
code_comment_test.go feat(review): add structured category and severity to findings (#311) 2026-07-07 13:08:41 +08:00
code_search.go fix: enable code_search to find content in untracked files 2026-06-26 00:01:44 +08:00
code_search_test.go test: improve coverage for tool package from 79.5% to 93.6% 2026-06-27 11:00:23 +08:00
comment_collector.go feat: add ocr scan for full-file code review (#93) 2026-06-24 22:07:25 +08:00
comment_collector_test.go test: improve coverage for tool package from 79.5% to 93.6% 2026-06-27 11:00:23 +08:00
definitions.go feat: add standard MCP tool support (#212) 2026-07-01 19:10:16 +08:00
definitions_test.go feat: add standard MCP tool support (#212) 2026-07-01 19:10:16 +08:00
file_find.go feat: add ocr scan for full-file code review (#93) 2026-06-24 22:07:25 +08:00
file_find_test.go test: improve coverage for tool package from 79.5% to 93.6% 2026-06-27 11:00:23 +08:00
file_read.go perf(tool): stream file reads line-by-line to avoid full-file memory allocation 2026-06-06 20:59:05 +08:00
file_read_diff.go fix(tool): make Registry and DiffMap concurrency-safe via freeze semantics 2026-06-06 19:41:11 +08:00
file_read_diff_test.go test: add unit tests for pure logic functions across 6 packages 2026-06-26 22:41:35 +08:00
file_read_test.go test: improve coverage for tool package from 79.5% to 93.6% 2026-06-27 11:00:23 +08:00
filereader.go Fix workspace symlink diff containment (#125) 2026-06-15 00:03:36 +08:00
filereader_read_test.go fix(tool): resolve file_read paths against git top-level in monorepos (#309) 2026-07-07 20:06:28 +08:00
filereader_test.go test: add unit tests for pure logic functions across 6 packages 2026-06-26 22:41:35 +08:00
response_message.go feat: init 2026-05-20 22:03:52 +08:00
response_message_test.go test: improve coverage for tool package from 79.5% to 93.6% 2026-06-27 11:00:23 +08:00
stub.go fix(tool): propagate context.Context to all tool providers to enable subprocess cancellation 2026-06-06 19:26:34 +08:00
stub_test.go test: improve coverage for tool package from 79.5% to 93.6% 2026-06-27 11:00:23 +08:00