mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-22 05:14:59 +00:00
fix: prevent name modification when using co-authored-by
This commit is contained in:
parent
d5671c2879
commit
48f89f226f
2 changed files with 8 additions and 7 deletions
|
@ -58,6 +58,7 @@ class GitRepo:
|
|||
commit_prompt=None,
|
||||
subtree_only=False,
|
||||
git_commit_verify=True,
|
||||
attribute_co_authored_by=False, # Added parameter
|
||||
):
|
||||
self.io = io
|
||||
self.models = models
|
||||
|
@ -69,8 +70,7 @@ class GitRepo:
|
|||
self.attribute_committer = attribute_committer
|
||||
self.attribute_commit_message_author = attribute_commit_message_author
|
||||
self.attribute_commit_message_committer = attribute_commit_message_committer
|
||||
# Ensure attribute_co_authored_by is initialized, default to False if not provided
|
||||
self.attribute_co_authored_by = getattr(self, 'attribute_co_authored_by', False)
|
||||
self.attribute_co_authored_by = attribute_co_authored_by # Assign from parameter
|
||||
self.commit_prompt = commit_prompt
|
||||
self.subtree_only = subtree_only
|
||||
self.git_commit_verify = git_commit_verify
|
||||
|
@ -158,9 +158,9 @@ class GitRepo:
|
|||
if coder and hasattr(coder, "main_model") and coder.main_model.name:
|
||||
model_name = coder.main_model.name
|
||||
commit_message_trailer = f"\n\nCo-authored-by: aider ({model_name}) <noreply@aider.dev>"
|
||||
# Only modify author/committer if explicitly requested alongside co-authored-by
|
||||
use_attribute_author = attribute_author
|
||||
use_attribute_committer = attribute_committer
|
||||
# If co-authored-by is used, disable author/committer name modification
|
||||
use_attribute_author = False
|
||||
use_attribute_committer = False
|
||||
else:
|
||||
# Original behavior when co-authored-by is false
|
||||
use_attribute_author = attribute_author
|
||||
|
|
|
@ -297,8 +297,9 @@ class TestRepo(unittest.TestCase):
|
|||
commit = raw_repo.head.commit
|
||||
self.assertIn("Co-authored-by: aider (gpt-test-combo) <noreply@aider.dev>", commit.message)
|
||||
self.assertEqual(commit.message.splitlines()[0], "Aider combo edit")
|
||||
self.assertEqual(commit.author.name, "Test User (aider)") # Should BE modified
|
||||
self.assertEqual(commit.committer.name, "Test User (aider)") # Should BE modified
|
||||
# When co-authored-by is true, name modification should be disabled
|
||||
self.assertEqual(commit.author.name, "Test User") # Should NOT be modified
|
||||
self.assertEqual(commit.committer.name, "Test User") # Should NOT be modified
|
||||
|
||||
|
||||
def test_commit_without_co_authored_by(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue