This commit is contained in:
Paul Gauthier 2025-05-08 15:13:38 -07:00
parent b40baaceea
commit 38e7f04e60
5 changed files with 115 additions and 45 deletions

View file

@ -22,4 +22,4 @@ Don't leave out any lines or the diff patch won't apply correctly.
To make a new file, show a diff from `--- /dev/null` to `+++ path/to/new/file.ext`.
{final_reminders}
""" # noqa
""" # noqa

View file

@ -1,5 +1,4 @@
import os
import oslex
import re
import shlex
import subprocess
@ -9,6 +8,7 @@ import warnings
from dataclasses import dataclass
from pathlib import Path
import oslex
from grep_ast import TreeContext, filename_to_lang
from grep_ast.tsl import get_parser # noqa: E402

View file

@ -72,7 +72,7 @@ class GitRepo:
commit_prompt=None,
subtree_only=False,
git_commit_verify=True,
attribute_co_authored_by=False, # Added parameter
attribute_co_authored_by=False, # Added parameter
):
self.io = io
self.models = models
@ -84,7 +84,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
self.attribute_co_authored_by = attribute_co_authored_by # Assign from parameter
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
@ -227,7 +227,6 @@ class GitRepo:
effective_author = True if attribute_author is None else attribute_author
effective_committer = True if attribute_committer is None else attribute_committer
# Determine commit message prefixing
prefix_commit_message = aider_edits and (
attribute_commit_message_author or attribute_commit_message_committer
@ -247,9 +246,7 @@ class GitRepo:
# Author modification applies only to aider edits.
# It's used if effective_author is True AND (co-authored-by is False OR author was explicitly set).
use_attribute_author = (
aider_edits
and effective_author
and (not attribute_co_authored_by or author_explicit)
aider_edits and effective_author and (not attribute_co_authored_by or author_explicit)
)
# Committer modification applies regardless of aider_edits (based on tests).
@ -258,7 +255,6 @@ class GitRepo:
not (aider_edits and attribute_co_authored_by) or committer_explicit
)
if not commit_message:
commit_message = "(no commit message provided)"
@ -291,7 +287,9 @@ class GitRepo:
with contextlib.ExitStack() as stack:
if use_attribute_committer:
stack.enter_context(
set_git_env("GIT_COMMITTER_NAME", committer_name, original_committer_name_env)
set_git_env(
"GIT_COMMITTER_NAME", committer_name, original_committer_name_env
)
)
if use_attribute_author:
stack.enter_context(