Skip to content

fix(tool): preserve colon paths in code_search - #864

Open
RerankerGuo wants to merge 1 commit into
alibaba:mainfrom
RerankerGuo:fix/code-search-colon-paths
Open

fix(tool): preserve colon paths in code_search#864
RerankerGuo wants to merge 1 commit into
alibaba:mainfrom
RerankerGuo:fix/code-search-colon-paths

Conversation

@RerankerGuo

Copy link
Copy Markdown
Contributor

Description

code_search parsed git grep output by splitting each line on :. A valid
path such as foo:bar.go therefore produced:

foo:bar.go:2:// needle

The parser treated bar.go as the line number, failed integer conversion, and
silently dropped the match.

This change requests Git's NUL-delimited output and parses records as:

path\0line\0content\n

Commit-mode results keep their existing ref:path prefix handling, while the
public output format remains unchanged. A real-repository regression test
covers both a colon-containing path and an ordinary path in workspace and
commit modes.

The existing per-file result cap and truncation-reporting semantics are
intentionally unchanged.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • CI / Build / Tooling

How Has This Been Tested?

  • make check
  • make test
  • make build
  • make coverage - 90.2%, meeting the 90% threshold
  • Real temporary Git repositories in workspace and commit modes

Before the fix, the regression test returned only plain.go; the
foo:bar.go match disappeared. After the fix, both files retain the expected
line number and content in both review modes. The focused test and the full
internal/tool package pass with the race detector.

Self-review used OCR Delegation Mode with the host agent:
2/2 changed files reviewed, 0 skipped, 0 blocking findings.

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • Documentation is not required for this internal output parser fix
  • I have signed the CLA

Related Issues

No existing issue found. All open issues, pull request text, and open pull
request changed files were checked before implementation; no competing
code_search path-parser change was found.

Parse NUL-delimited git grep output so filenames containing colons are not mistaken for line-number separators. Cover workspace and commit modes with real repository fixtures.

Test: make check && make test && make build && make coverage
@github-actions

Copy link
Copy Markdown
Contributor

OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s).

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.

1 participant