Skip to content

Examples and guides for using the OpenAI API

Preserve files when patch moves target the same path (#3203)

Konstantine Kahadze3d3c283b3078
diff --git a/examples/gpt-5/apply_patch.py b/examples/gpt-5/apply_patch.py
index a0df1430..1d66103b 100644
--- a/examples/gpt-5/apply_patch.py
+++ b/examples/gpt-5/apply_patch.py
@@ -427,7 +427,7 @@ def apply_commit(commit: Commit, write_fn: Callable, remove_fn: Callable) -> Non
elif change.type == ActionType.ADD:
write_fn(path, change.new_content)
elif change.type == ActionType.UPDATE:
- if change.move_path:
+ if change.move_path and change.move_path != path:
write_fn(change.move_path, change.new_content)
remove_fn(path)
else: