mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-05 04:05:04 +00:00
feat: Add user language instruction to commit prompt
This commit is contained in:
parent
81b86441fd
commit
23714d7db6
2 changed files with 15 additions and 3 deletions
|
@ -13,11 +13,13 @@ Generate a one-line commit message for those changes.
|
||||||
The commit message should be structured as follows: <type>: <description>
|
The commit message should be structured as follows: <type>: <description>
|
||||||
Use these for <type>: fix, feat, build, chore, ci, docs, style, refactor, perf, test
|
Use these for <type>: fix, feat, build, chore, ci, docs, style, refactor, perf, test
|
||||||
|
|
||||||
Ensure the commit message:
|
Ensure the commit message:{language_instruction}
|
||||||
- Starts with the appropriate prefix.
|
- Starts with the appropriate prefix.
|
||||||
- Is in the imperative mood (e.g., \"add feature\" not \"added feature\" or \"adding feature\").
|
- Is in the imperative mood (e.g., \"add feature\" not \"added feature\" or \"adding feature\").
|
||||||
- Does not exceed 72 characters.
|
- Does not exceed 72 characters.
|
||||||
|
|
||||||
|
Reply only with the one-line commit message, without any additional text, explanations, or line breaks.
|
||||||
|
|
||||||
Reply only with the one-line commit message, without any additional text, explanations, \
|
Reply only with the one-line commit message, without any additional text, explanations, \
|
||||||
or line breaks.
|
or line breaks.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -207,7 +207,12 @@ class GitRepo:
|
||||||
if message:
|
if message:
|
||||||
commit_message = message
|
commit_message = message
|
||||||
else:
|
else:
|
||||||
commit_message = self.get_commit_message(diffs, context)
|
user_language = None
|
||||||
|
if coder:
|
||||||
|
user_language = coder.get_user_language()
|
||||||
|
commit_message = self.get_commit_message(diffs, context, user_language)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Retrieve attribute settings, prioritizing coder.args if available
|
# Retrieve attribute settings, prioritizing coder.args if available
|
||||||
if coder and hasattr(coder, "args"):
|
if coder and hasattr(coder, "args"):
|
||||||
|
@ -319,7 +324,7 @@ class GitRepo:
|
||||||
except (ValueError, OSError):
|
except (ValueError, OSError):
|
||||||
return self.repo.git_dir
|
return self.repo.git_dir
|
||||||
|
|
||||||
def get_commit_message(self, diffs, context):
|
def get_commit_message(self, diffs, context, user_language=None):
|
||||||
diffs = "# Diffs:\n" + diffs
|
diffs = "# Diffs:\n" + diffs
|
||||||
|
|
||||||
content = ""
|
content = ""
|
||||||
|
@ -328,6 +333,11 @@ class GitRepo:
|
||||||
content += diffs
|
content += diffs
|
||||||
|
|
||||||
system_content = self.commit_prompt or prompts.commit_system
|
system_content = self.commit_prompt or prompts.commit_system
|
||||||
|
language_instruction = ""
|
||||||
|
if user_language:
|
||||||
|
language_instruction = f"\n- Is written in {user_language}."
|
||||||
|
system_content = system_content.format(language_instruction=language_instruction)
|
||||||
|
|
||||||
messages = [
|
messages = [
|
||||||
dict(role="system", content=system_content),
|
dict(role="system", content=system_content),
|
||||||
dict(role="user", content=content),
|
dict(role="user", content=content),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue