mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 14:55:00 +00:00
notify when preparing dirty commit; skip if /exit or /commit is input
This commit is contained in:
parent
fde537cd7f
commit
967cb1bd8d
2 changed files with 17 additions and 5 deletions
|
@ -402,9 +402,13 @@ class Coder:
|
|||
return
|
||||
|
||||
def should_dirty_commit(self, inp):
|
||||
is_commit_command = inp and inp.startswith("/commit")
|
||||
if is_commit_command:
|
||||
return
|
||||
cmds = self.commands.matching_commands(inp)
|
||||
if cmds:
|
||||
matching_commands, _, _ = cmds
|
||||
if len(matching_commands) == 1:
|
||||
cmd = matching_commands[0]
|
||||
if cmd in ("/exit", "/commit"):
|
||||
return
|
||||
|
||||
if not self.dirty_commits:
|
||||
return
|
||||
|
@ -436,6 +440,7 @@ class Coder:
|
|||
self.num_control_c = 0
|
||||
|
||||
if self.should_dirty_commit(inp):
|
||||
self.io.tool_output("Git repo has uncommitted changes, preparing commit...")
|
||||
self.commit(ask=True, which="repo_files")
|
||||
|
||||
# files changed, move cur messages back behind the files messages
|
||||
|
|
|
@ -46,7 +46,7 @@ class Commands:
|
|||
else:
|
||||
self.io.tool_output(f"Error: Command {cmd_name} not found.")
|
||||
|
||||
def run(self, inp):
|
||||
def matching_commands(self, inp):
|
||||
words = inp.strip().split()
|
||||
if not words:
|
||||
return
|
||||
|
@ -56,12 +56,19 @@ class Commands:
|
|||
|
||||
all_commands = self.get_commands()
|
||||
matching_commands = [cmd for cmd in all_commands if cmd.startswith(first_word)]
|
||||
return matching_commands, first_word, rest_inp
|
||||
|
||||
def run(self, inp):
|
||||
res = self.matching_commands(inp)
|
||||
if res is None:
|
||||
return
|
||||
matching_commands, first_word, rest_inp = res
|
||||
if len(matching_commands) == 1:
|
||||
return self.do_run(matching_commands[0][1:], rest_inp)
|
||||
elif len(matching_commands) > 1:
|
||||
self.io.tool_error(f"Ambiguous command: {', '.join(matching_commands)}")
|
||||
else:
|
||||
self.io.tool_error(f"Error: {first_word} is not a valid command.")
|
||||
self.io.tool_error(f"Invalid command: {first_word}")
|
||||
|
||||
# any method called cmd_xxx becomes a command automatically.
|
||||
# each one must take an args param.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue