Skip to content

Refactor duplicated search and index logic - #140

Merged
Shengyu Fu (shengyfu) merged 1 commit into
mainfrom
shengyfu-duplicate-code-refactor
Sep 8, 2026
Merged

Shengyu Fu (shengyfu) merged 1 commit into
mainfrom
shengyfu-duplicate-code-refactor

Conversation

@shengyfu

Copy link
Copy Markdown
Member

Summary

  • Share file-selection handling and scoped sorting across local, indexed, and server-backed searches.
  • Reuse server string-array parsing and collected ignore-matcher publication without changing validation order, snapshot handling, or watcher recovery.
  • Centralize buffered posting/lookup serialization and reuse existing snapshot-aware hybrid-index helpers.

Preserves public APIs, the on-disk format, buffer sizes, output, and error handling. Similar-looking paths with different semantics remain separate. Adds focused regression coverage for sorting, binary/nonmatching files, parser defaults, serialization boundaries and I/O failures, and overlay/snapshot consistency.

Validation

  • cargo fmt --all -- --check
  • cargo clippy --workspace --benches -- -D warnings
  • Focused CLI sorting, file-selection, server parsing, ignore publication, watcher, and warm-start tests.
  • Focused core builder, external-sort, and on-disk serialization tests, plus snapshot, case-insensitive round-trip, and corrupt-index integration tests.
  • Final cross-component run: cargo test -p tgrep-cli --test indexed_files --test concurrent_search

Copilot AI balanced review requested due to automatic review settings September 8, 2026 00:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved approval-blocking issues were identified.

Review tier: Balanced
Findings: None

What changed in this PR

Refactors duplicated search, indexing, serialization, and server logic while preserving existing behavior and public APIs.

Changes:

  • Centralizes sorting and file-selection handling.
  • Shares serialization, parsing, and ignore-publication helpers.
  • Adds focused regression coverage.
File Description
tgrep-core/​tests/​snapshot_consistency.rs Tests overlay and snapshot precedence.
tgrep-core/​src/​ondisk.rs Adds shared serialization helpers.
tgrep-core/​src/​hybrid.rs Reuses snapshot-aware lookup helpers.
tgrep-core/​src/​external.rs Uses shared serialization logic.
tgrep-core/​src/​builder.rs Removes duplicate serialization helpers.
tgrep-cli/​tests/​ripgrep_compat.rs Tests explicit-file selection behavior.
tgrep-cli/​tests/​indexed_files.rs Tests indexed and server sorting.
tgrep-cli/​src/​serve.rs Shares parsing and ignore-publication logic.
tgrep-cli/​src/​search.rs Centralizes sorting and file-selection outcomes.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@shengyfu
Shengyu Fu (shengyfu) merged commit 10c7388 into main Sep 8, 2026
10 checks passed
@shengyfu
Shengyu Fu (shengyfu) deleted the shengyfu-duplicate-code-refactor branch September 8, 2026 00:57
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.

2 participants