31 lines
849 B
Python
31 lines
849 B
Python
CONVENTIONAL_PROMPT = """Generate a conventional commit message for these changes.
|
|
Format: <type>(<scope>): <description>
|
|
|
|
Types: feat, fix, docs, style, refactor, test, chore
|
|
|
|
Changes:
|
|
{diff}
|
|
|
|
Recent commits for context:
|
|
{history}
|
|
|
|
Respond with only the commit message."""
|
|
|
|
DEFAULT_PROMPT = """Generate a concise commit message for these changes.
|
|
|
|
Changes:
|
|
{diff}
|
|
|
|
Recent commits for context:
|
|
{history}
|
|
|
|
Respond with only the commit message."""
|
|
|
|
def build_prompt(diff, conventional=False, history=None):
|
|
"""Build prompt for commit message generation."""
|
|
diff_text = "\n".join(diff) if isinstance(diff, list) else str(diff)
|
|
history_text = "\n".join(history) if history else "No previous commits"
|
|
|
|
template = CONVENTIONAL_PROMPT if conventional else DEFAULT_PROMPT
|
|
return template.format(diff=diff_text, history=history_text)
|