mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-08 21:55:00 +00:00
Rename UndoChange's file argument to file_path
This commit is contained in:
parent
dfd248245c
commit
24042e91d5
2 changed files with 26 additions and 27 deletions
|
@ -698,9 +698,9 @@ class NavigatorCoder(Coder):
|
|||
|
||||
elif norm_tool_name == 'undochange':
|
||||
change_id = params.get('change_id')
|
||||
last_file = params.get('last_file')
|
||||
file_path = params.get('file_path')
|
||||
|
||||
result_message = self._execute_undo_change(change_id, last_file)
|
||||
result_message = self._execute_undo_change(change_id, file_path)
|
||||
|
||||
elif norm_tool_name == 'listchanges':
|
||||
file_path = params.get('file_path')
|
||||
|
@ -2322,13 +2322,13 @@ Just reply with fixed versions of the {blocks} above that failed to match.
|
|||
self.io.tool_error(f"Error in DeleteBlock: {str(e)}\n{traceback.format_exc()}") # Add traceback
|
||||
return f"Error: {str(e)}"
|
||||
|
||||
def _execute_undo_change(self, change_id=None, last_file=None):
|
||||
def _execute_undo_change(self, change_id=None, file_path=None):
|
||||
"""
|
||||
Undo a specific change by ID, or the last change to a file.
|
||||
|
||||
Parameters:
|
||||
- change_id: ID of the change to undo
|
||||
- last_file: Path to file where the last change should be undone
|
||||
- file_path: Path to file where the last change should be undone
|
||||
|
||||
|
||||
Returns a result message.
|
||||
|
@ -2336,20 +2336,20 @@ Just reply with fixed versions of the {blocks} above that failed to match.
|
|||
# Note: Undo does not have a dry_run parameter as it's inherently about reverting a previous action.
|
||||
try:
|
||||
# Validate parameters
|
||||
if change_id is None and last_file is None:
|
||||
self.io.tool_error("Must specify either change_id or last_file for UndoChange")
|
||||
return "Error: Must specify either change_id or last_file" # Improve Point 4
|
||||
if change_id is None and file_path is None:
|
||||
self.io.tool_error("Must specify either change_id or file_path for UndoChange")
|
||||
return "Error: Must specify either change_id or file_path" # Improve Point 4
|
||||
|
||||
# If last_file is specified, get the most recent change for that file
|
||||
if last_file:
|
||||
abs_path = self.abs_root_path(last_file)
|
||||
# If file_path is specified, get the most recent change for that file
|
||||
if file_path:
|
||||
abs_path = self.abs_root_path(file_path)
|
||||
rel_path = self.get_rel_fname(abs_path)
|
||||
|
||||
change_id = self.change_tracker.get_last_change(rel_path)
|
||||
if not change_id:
|
||||
# Improve error message (Point 4)
|
||||
self.io.tool_error(f"No tracked changes found for file '{last_file}' to undo.")
|
||||
return f"Error: No changes found for file '{last_file}'"
|
||||
self.io.tool_error(f"No tracked changes found for file '{file_path}' to undo.")
|
||||
return f"Error: No changes found for file '{file_path}'"
|
||||
# Attempt to get undo information from the tracker
|
||||
success, message, change_info = self.change_tracker.undo_change(change_id)
|
||||
|
||||
|
@ -3029,7 +3029,6 @@ Just reply with fixed versions of the {blocks} above that failed to match.
|
|||
target_insertion_line = len(target_content.splitlines()) if target_content else 0
|
||||
target_diff_snippet = self._generate_diff_snippet_insert(original_target_content, target_insertion_line, extracted_lines)
|
||||
|
||||
# --- Handle Dry Run ---
|
||||
# --- Handle Dry Run ---
|
||||
if dry_run:
|
||||
num_extracted = end_line - start_line + 1
|
||||
|
|
|
@ -82,8 +82,8 @@ Act as an expert software engineer with the ability to autonomously navigate and
|
|||
- **IndentLines**: `[tool_call(IndentLines, file_path="...", start_pattern="...", end_pattern="...", indent_levels=1, near_context="...", occurrence=1, dry_run=False)]`
|
||||
Indent (`indent_levels` > 0) or unindent (`indent_levels` < 0) a block. Use `end_pattern` or `line_count` for range. Use `near_context` and `occurrence` (optional, default 1, -1 for last) for `start_pattern`. `dry_run=True` simulates.
|
||||
|
||||
- **UndoChange**: `[tool_call(UndoChange, change_id="a1b2c3d4")]` or `[tool_call(UndoChange, last_file="...")]`
|
||||
Undo a specific change by ID, or the last change made to `last_file`.
|
||||
- **UndoChange**: `[tool_call(UndoChange, change_id="a1b2c3d4")]` or `[tool_call(UndoChange, file_path="...")]`
|
||||
Undo a specific change by ID, or the last change made to the specified `file_path`.
|
||||
|
||||
- **ListChanges**: `[tool_call(ListChanges, file_path="...", limit=5)]`
|
||||
List recent changes, optionally filtered by `file_path` and limited.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue