mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 22:34:59 +00:00
finish removing aider: prefix
This commit is contained in:
parent
0cc00f2a1e
commit
5a3627de6e
4 changed files with 17 additions and 20 deletions
|
@ -1,6 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import datetime
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
|
@ -28,7 +27,7 @@ from aider.mdstream import MarkdownStream
|
|||
from aider.repo import GitRepo
|
||||
from aider.repomap import RepoMap
|
||||
from aider.sendchat import send_with_retries
|
||||
from aider.utils import is_image_file, format_messages, format_content
|
||||
from aider.utils import format_content, format_messages, is_image_file
|
||||
|
||||
from ..dump import dump # noqa: F401
|
||||
|
||||
|
@ -1385,7 +1384,7 @@ class Coder:
|
|||
|
||||
def auto_commit(self, edited):
|
||||
# context = self.get_context_from_history(self.cur_messages)
|
||||
res = self.repo.commit(fnames=edited, prefix="aider: ")
|
||||
res = self.repo.commit(fnames=edited, aider_edits=True)
|
||||
if res:
|
||||
commit_hash, commit_message = res
|
||||
self.last_aider_commit_hash = commit_hash
|
||||
|
|
|
@ -110,9 +110,6 @@ class GUI:
|
|||
show_undo = False
|
||||
res = ""
|
||||
if commit_hash:
|
||||
prefix = "aider: "
|
||||
if commit_message.startswith(prefix):
|
||||
commit_message = commit_message[len(prefix) :]
|
||||
res += f"Commit `{commit_hash}`: {commit_message} \n"
|
||||
if commit_hash == self.coder.last_aider_commit_hash:
|
||||
show_undo = True
|
||||
|
|
|
@ -59,7 +59,7 @@ class GitRepo:
|
|||
if aider_ignore_file:
|
||||
self.aider_ignore_file = Path(aider_ignore_file)
|
||||
|
||||
def commit(self, fnames=None, context=None, prefix=None, message=None):
|
||||
def commit(self, fnames=None, context=None, message=None, aider_edits=False):
|
||||
if not fnames and not self.repo.is_dirty():
|
||||
return
|
||||
|
||||
|
@ -75,9 +75,6 @@ class GitRepo:
|
|||
if not commit_message:
|
||||
commit_message = "(no commit message provided)"
|
||||
|
||||
if prefix:
|
||||
commit_message = prefix + commit_message
|
||||
|
||||
full_commit_message = commit_message
|
||||
if context:
|
||||
full_commit_message += "\n\n# Aider chat conversation:\n\n" + context
|
||||
|
@ -91,6 +88,7 @@ class GitRepo:
|
|||
else:
|
||||
cmd += ["-a"]
|
||||
|
||||
if aider_edits:
|
||||
user_name = self.repo.config_reader().get_value("user", "name")
|
||||
committer_name = f"{user_name} (aider)"
|
||||
original_committer_name = os.environ.get("GIT_COMMITTER_NAME")
|
||||
|
@ -101,6 +99,7 @@ class GitRepo:
|
|||
self.io.tool_output(f"Commit {commit_hash} {commit_message}")
|
||||
|
||||
# Restore the original GIT_COMMITTER_NAME
|
||||
if aider_edits:
|
||||
if original_committer_name is not None:
|
||||
os.environ["GIT_COMMITTER_NAME"] = original_committer_name
|
||||
else:
|
||||
|
|
|
@ -137,7 +137,7 @@ class TestRepo(unittest.TestCase):
|
|||
# Assert that the returned message is the expected one
|
||||
self.assertEqual(result, 'a good "commit message"')
|
||||
|
||||
@patch("aider.repo.simple_send_with_retries")
|
||||
@patch("aider.repo.GitRepo.get_commit_message")
|
||||
def test_commit_with_custom_committer_name(self, mock_send):
|
||||
mock_send.return_value = '"a good commit message"'
|
||||
|
||||
|
@ -156,7 +156,7 @@ class TestRepo(unittest.TestCase):
|
|||
|
||||
# commit a change
|
||||
fname.write_text("new content")
|
||||
git_repo.commit(fnames=[str(fname)])
|
||||
git_repo.commit(fnames=[str(fname)], aider_edits=True)
|
||||
|
||||
# check the committer name
|
||||
commit = raw_repo.head.commit
|
||||
|
@ -165,6 +165,8 @@ class TestRepo(unittest.TestCase):
|
|||
# check that the original committer name is restored
|
||||
original_committer_name = os.environ.get("GIT_COMMITTER_NAME")
|
||||
self.assertIsNone(original_committer_name)
|
||||
|
||||
def test_get_tracked_files(self):
|
||||
# Create a temporary directory
|
||||
tempdir = Path(tempfile.mkdtemp())
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue