From 48f89f226fac3d407d40574d921bf5df065cda71 Mon Sep 17 00:00:00 2001 From: "Andrew Grigorev (aider)" Date: Sat, 12 Apr 2025 17:51:58 +0300 Subject: [PATCH] fix: prevent name modification when using co-authored-by --- aider/repo.py | 10 +++++----- tests/basic/test_repo.py | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/aider/repo.py b/aider/repo.py index 7e04d89ee..f0d436526 100644 --- a/aider/repo.py +++ b/aider/repo.py @@ -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}) " - # 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 diff --git a/tests/basic/test_repo.py b/tests/basic/test_repo.py index 945de84f8..2c68c8f00 100644 --- a/tests/basic/test_repo.py +++ b/tests/basic/test_repo.py @@ -297,8 +297,9 @@ class TestRepo(unittest.TestCase): commit = raw_repo.head.commit self.assertIn("Co-authored-by: aider (gpt-test-combo) ", 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):