MCPcopy
hub / github.com/Aider-AI/aider / commit

Method commit

aider/repo.py:131–318  ·  view source on GitHub ↗

Commit the specified files or all dirty files if none are specified. Args: fnames (list, optional): List of filenames to commit. Defaults to None (commit all dirty files). context (str, optional): Context for generating c

(self, fnames=None, context=None, message=None, aider_edits=False, coder=None)

Source from the content-addressed store, hash-verified

129 self.aider_ignore_file = Path(aider_ignore_file)
130
131 def commit(self, fnames=None, context=None, message=None, aider_edits=False, coder=None):
132 """
133 Commit the specified files or all dirty files if none are specified.
134
135 Args:
136 fnames (list, optional): List of filenames to commit. Defaults to None (commit all
137 dirty files).
138 context (str, optional): Context for generating commit message. Defaults to None.
139 message (str, optional): Explicit commit message. Defaults to None (generate message).
140 aider_edits (bool, optional): Whether the changes were made by Aider. Defaults to False.
141 This affects attribution logic.
142 coder (Coder, optional): The Coder instance, used for config and model info.
143 Defaults to None.
144
145 Returns:
146 tuple(str, str) or None: The commit hash and commit message if successful,
147 else None.
148
149 Attribution Logic:
150 ------------------
151 This method handles Git commit attribution based on configuration flags and whether
152 Aider generated the changes (`aider_edits`).
153
154 Key Concepts:
155 - Author: The person who originally wrote the code changes.
156 - Committer: The person who last applied the commit to the repository.
157 - aider_edits=True: Changes were generated by Aider (LLM).
158 - aider_edits=False: Commit is user-driven (e.g., /commit manually staged changes).
159 - Explicit Setting: A flag (--attribute-...) is set to True or False
160 via command line or config file.
161 - Implicit Default: A flag is not explicitly set, defaulting to None in args, which is
162 interpreted as True unless overridden by other logic.
163
164 Flags:
165 - --attribute-author: Modify Author name to "User Name (aider)".
166 - --attribute-committer: Modify Committer name to "User Name (aider)".
167 - --attribute-co-authored-by: Add
168 "Co-authored-by: aider (<model>) <aider@aider.chat>" trailer to commit message.
169
170 Behavior Summary:
171
172 1. When aider_edits = True (AI Changes):
173 - If --attribute-co-authored-by=True:
174 - Co-authored-by trailer IS ADDED.
175 - Author/Committer names are NOT modified by default (co-authored-by takes precedence).
176 - EXCEPTION: If --attribute-author/--attribute-committer is EXPLICITLY True, the
177 respective name IS modified (explicit overrides precedence).
178 - If --attribute-co-authored-by=False:
179 - Co-authored-by trailer is NOT added.
180 - Author/Committer names ARE modified by default (implicit True).
181 - EXCEPTION: If --attribute-author/--attribute-committer is EXPLICITLY False,
182 the respective name is NOT modified.
183
184 2. When aider_edits = False (User Changes):
185 - --attribute-co-authored-by is IGNORED (trailer never added).
186 - Author name is NEVER modified (--attribute-author ignored).
187 - Committer name IS modified by default (implicit True, as Aider runs `git commit`).
188 - EXCEPTION: If --attribute-committer is EXPLICITLY False, the name is NOT modified.

Calls 9

get_diffsMethod · 0.95
get_commit_messageMethod · 0.95
abs_root_pathMethod · 0.95
get_head_commit_shaMethod · 0.95
set_git_envFunction · 0.85
is_dirtyMethod · 0.80
get_user_languageMethod · 0.80
tool_errorMethod · 0.45
tool_outputMethod · 0.45