Skip to content

fix(core): show what a patch Add File overwrites - #68595

Closed
TianYuan1024 wants to merge 1 commit into
anomalyco:devfrom
TianYuan1024:patch-add-overwrite
Closed

TianYuan1024 wants to merge 1 commit into
anomalyco:devfrom
TianYuan1024:patch-add-overwrite

Conversation

@TianYuan1024

Copy link
Copy Markdown

Issue for this PR

Closes #68592

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

*** Add File over an existing file still overwrites it, as before. Now the patch tool reads the current content first, the same way write does, so the approval diff, the result metadata and the model output show it as modified (-old +new, M <path>) instead of a new file.

  • If an earlier hunk in the same patch already changed or deleted the file, it uses that state.
  • If the file can't be read, it is shown as new, as before.

No feature flag: this is a bug fix.

How did you verify your code works?

  • Extended the existing test "adds files by overwriting existing targets" to check the approval and result. It fails without the fix (A existing.txt, 0 deletions) and passes with it.
  • The main add/update/delete test now counts 3 reads before approval instead of 2, because the added path is read too.
  • bun run script/test.ts test/tool-patch.test.ts --rerun-each 10: 420 pass.
  • Full packages/core suite: 8619 pass, 2 fail. The 2 failures are shell tests that macOS bash 3.2 cannot run (core: two tests fail on macOS with the stock bash 3.2 #67810). They also fail without this change.
  • bun run typecheck:tsc in packages/core and bun run check: pass.

Screenshots / recordings

N/A, not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@TianYuan1024

Copy link
Copy Markdown
Author

Closing in favor of #68594, which makes the same change.

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.

patch: Add File over an existing file is shown as a new file in the approval

1 participant