aider output is red; better commit prompt

This commit is contained in:
Paul Gauthier 2023-05-09 21:05:13 -07:00
parent 448002bd0d
commit e7604a6545
2 changed files with 14 additions and 16 deletions

View file

@ -91,27 +91,23 @@ class Coder:
new_files.append(relative_fname) new_files.append(relative_fname)
if new_files: if new_files:
self.console.print(f"[red bold]Files not tracked in {repo.git_dir}:") self.console.print(f"[red]Files not tracked in {repo.git_dir}:")
for fn in new_files: for fn in new_files:
self.console.print(f"[red bold] {fn}") self.console.print(f"[red] {fn}")
if Confirm.ask("[bold red]Add them?", console=self.console, default="y"): if Confirm.ask("[bold]Add them?", console=self.console, default="y"):
for relative_fname in new_files: for relative_fname in new_files:
repo.git.add(relative_fname) repo.git.add(relative_fname)
self.console.print( self.console.print(f"[red]Added {relative_fname} to the git repo")
f"[red bold]Added {relative_fname} to the git repo"
)
show_files = ", ".join(new_files) show_files = ", ".join(new_files)
commit_message = ( commit_message = (
f"Initial commit: Added new files to the git repo: {show_files}" f"Initial commit: Added new files to the git repo: {show_files}"
) )
repo.git.commit("-m", commit_message, "--no-verify") repo.git.commit("-m", commit_message, "--no-verify")
self.console.print( self.console.print(
f"[green bold]Committed new files with message: {commit_message}" f"[red]Committed new files with message: {commit_message}"
) )
else: else:
self.console.print( self.console.print("[red]Skipped adding new files to the git repo.")
"[red bold]Skipped adding new files to the git repo."
)
return return
self.repo = repo self.repo = repo
@ -280,9 +276,9 @@ class Coder:
stream=True, stream=True,
) )
break break
except RateLimitError as e: except RateLimitError:
retry_after = e.retry_after retry_after = 1
print(f"Rate limit exceeded. Retrying in {retry_after} seconds.") # print(f"Rate limit exceeded. Retrying in {retry_after} seconds.")
time.sleep(retry_after) time.sleep(retry_after)
if self.pretty and not silent: if self.pretty and not silent:
@ -342,9 +338,11 @@ class Coder:
if path not in self.fnames: if path not in self.fnames:
if not Path(path).exists(): if not Path(path).exists():
question = f"[red bold]Allow creation of new file {path}?" question = f"[red]Allow creation of new file {path}?"
else: else:
question = f"[red bold]Allow edits to {path} which was not previously provided?" question = (
f"[red]Allow edits to {path} which was not previously provided?"
)
if not Confirm.ask(question, console=self.console, default="y"): if not Confirm.ask(question, console=self.console, default="y"):
self.console.print(f"[red]Skipping edit to {path}") self.console.print(f"[red]Skipping edit to {path}")
continue continue

View file

@ -93,7 +93,7 @@ files_content_suffix = """Base any edits on the current contents of the files as
# COMMIT # COMMIT
commit_system = """You are an expert software engineer. commit_system = """You are an expert software engineer.
Review the provided context and diffs which are about to be committed to a git repo. Review the provided context and diffs which are about to be committed to a git repo.
Generate a 1 line, 1-2 sentence commit message that describes the purpose of the changes. Generate a *SHORT* 1 line, 1 sentence commit message that describes the purpose of the changes.
The commit message MUST be in the past tense. The commit message MUST be in the past tense.
It must describe the changes *which have been made* in the diffs! It must describe the changes *which have been made* in the diffs!
Reply with JUST the commit message, without quotes, comments, questions, etc! Reply with JUST the commit message, without quotes, comments, questions, etc!