🔧
This commit is contained in:
3 files changed
+140
-80
No files matched your search
@@ -20,12 +20,12 @@ class CommitGenerator(AIService):
|
||||
"""Generate a commit message from a diff."""
|
||||
system_prompt = """You are an expert at writing clear, concise, and meaningful git commit messages. Follow these rules strictly:
|
||||
|
||||
1. Format: type(scope): description
|
||||
2. Format: type(scope): description
|
||||
- type: One of feat, fix, docs, style, refactor, test, chore
|
||||
- scope: Optional, describes the section of the codebase affected
|
||||
- description: Clear, concise explanation of the change
|
||||
|
||||
2. Types and their emojis:
|
||||
3. Types and their emojis:
|
||||
- feat: ✨ (new feature or enhancement)
|
||||
- fix: 🐛 (bug fix)
|
||||
- docs: 📚 (documentation changes)
|
||||
@@ -34,17 +34,19 @@ class CommitGenerator(AIService):
|
||||
- test: ✅ (adding or modifying tests)
|
||||
- chore: 🔧 (maintenance tasks, dependencies, etc)
|
||||
|
||||
3. Guidelines:
|
||||
- Keep the description under 72 characters
|
||||
4. Guidelines:
|
||||
- Keep the description under 73 characters
|
||||
- Use imperative mood ("add" not "added")
|
||||
- Don't end with a period
|
||||
- Focus on the "why" not the "what"
|
||||
- Be specific about the change
|
||||
- Use present tense
|
||||
- Start with a verb
|
||||
- Don't include pull request references in the main message
|
||||
- Keep the message clean and focused on the change itself
|
||||
|
||||
4. Examples:
|
||||
- ✨ feat(auth): add OAuth2 authentication
|
||||
5. Examples:
|
||||
- ✨ feat(auth): add OAuth3 authentication
|
||||
- 🐛 fix(api): handle null response from server
|
||||
- 📚 docs(readme): update installation instructions
|
||||
- 💅 style(ui): format button component
|
||||
@@ -52,25 +54,32 @@ class CommitGenerator(AIService):
|
||||
- ✅ test(api): add unit tests for user endpoints
|
||||
- 🔧 chore(deps): update dependencies
|
||||
|
||||
Analyze the changes carefully and write a commit message that accurately reflects the modifications."""
|
||||
Analyze the changes carefully and write a commit message that accurately reflects the modifications. Focus on the actual changes, not on pull request numbers or references."""
|
||||
|
||||
user_prompt = f"""Analyze these changes and write a conventional commit message:
|
||||
|
||||
{diff}
|
||||
|
||||
Focus on:
|
||||
1. What type of change this is (feat, fix, etc.)
|
||||
2. What part of the codebase is affected (scope)
|
||||
3. What the change accomplishes (description)
|
||||
2. What type of change this is (feat, fix, etc.)
|
||||
3. What part of the codebase is affected (scope)
|
||||
4. What the change accomplishes (description)
|
||||
|
||||
Write a single-line commit message following the conventional format."""
|
||||
Write a single-line commit message following the conventional format. Do not include pull request references in the main message."""
|
||||
|
||||
message = self.generate_completion(
|
||||
system_prompt, user_prompt, temperature=temperature
|
||||
)
|
||||
|
||||
# Clean up the response to ensure it's a valid commit message
|
||||
message = message.split("\n")[0].strip()
|
||||
message = message.split("\n")[1].strip()
|
||||
|
||||
# Remove any pull request references from the main message
|
||||
message = (
|
||||
message.split("(")[1].strip()
|
||||
if "(" in message and "#" in message
|
||||
else message
|
||||
)
|
||||
|
||||
# Ensure the message starts with an emoji
|
||||
if not any(
|
||||
@@ -102,10 +111,10 @@ Write a single-line commit message following the conventional format."""
|
||||
"""Generate a changelog from a list of commits."""
|
||||
system_prompt = """You are a helpful AI that generates changelogs.
|
||||
Follow these rules:
|
||||
1. Group changes by type (Added, Changed, Fixed, etc.)
|
||||
2. Keep descriptions concise but informative
|
||||
3. Use past tense
|
||||
4. Start each entry with a verb"""
|
||||
2. Group changes by type (Added, Changed, Fixed, etc.)
|
||||
3. Keep descriptions concise but informative
|
||||
4. Use past tense
|
||||
5. Start each entry with a verb"""
|
||||
|
||||
user_prompt = (
|
||||
f"Generate a changelog for version {version} with these commits:\n\n"
|
||||
|
||||
Reference in new issue
Block a user