open-code-review/internal/diff
ZheNing Hu 283ec8558c
fix(diff): detect renamed and deleted files correctly in diff parsing (#105)
When a file was renamed on the target branch, ocr review emitted
'[ocr] WARNING: cannot read file <old path> at ref <to>: exit status 128'.

Two compounding bugs:

1. The parser required 'a/'/'b/' prefixes when matching '--- /dev/null' /
   '+++ /dev/null', but git emits these lines without prefixes, so
   IsNew/IsDeleted were never set and deleted files fell through to a
   doomed 'git show ref:<old path>'.

2. 'rename from' / 'rename to' extended headers were never parsed, and
   git diff/show call sites did not force rename detection, so renames
   degraded to delete+add whenever the user had diff.renames=false.

Fixes:
- Parse 'rename from'/'rename to', 'new file mode', 'deleted file mode'
  and unprefixed /dev/null markers in ParseDiffText.
- Pass --find-renames to all git diff/show invocations so rename
  detection no longer depends on user config.
- Add IsRenamed to model.Diff (json: is_renamed) and prefer it in
  diffStatus.
- Add parser unit tests and a range-mode rename regression test.

Fixes #99
2026-06-14 22:29:02 +08:00
..
git.go fix(diff): detect renamed and deleted files correctly in diff parsing (#105) 2026-06-14 22:29:02 +08:00
git_test.go fix(diff): detect renamed and deleted files correctly in diff parsing (#105) 2026-06-14 22:29:02 +08:00
hunk.go style: apply go fmt formatting 2026-06-03 17:34:28 +08:00
hunk_test.go feat: init 2026-05-20 22:03:52 +08:00
parser.go fix(diff): detect renamed and deleted files correctly in diff parsing (#105) 2026-06-14 22:29:02 +08:00
parser_test.go fix(diff): detect renamed and deleted files correctly in diff parsing (#105) 2026-06-14 22:29:02 +08:00
relocation.go feat(agent): integrate session recording and token tracking for re-location task 2026-05-30 23:25:12 +08:00
relocation_test.go refactor(llm): replace hand-rolled HTTP clients with official Anthropic and OpenAI SDKs 2026-06-06 19:26:34 +08:00
resolver.go feat(agent): integrate session recording and token tracking for re-location task 2026-05-30 23:25:12 +08:00
resolver_test.go refactor(diff): Simplify hunk resolution logic with helper functions 2026-05-23 00:36:51 +08:00