Compare commits

...

2 Commits

Author SHA1 Message Date
3bdbf2e621 Ruff
Some checks failed
Run Python tests (through Pytest) / Test (push) Successful in 24s
Verify Python project can be installed, loaded and have version checked / Test (push) Has been cancelled
2025-04-14 23:51:34 +02:00
7eab429f81 feat: include commit messages in pull request description 2025-04-14 23:51:30 +02:00
2 changed files with 37 additions and 2 deletions

View File

@ -138,6 +138,7 @@ For code tasks:
MODEL = None
def create_aider_command(issue: str) -> list[str]:
l = [
'aider',
@ -173,6 +174,31 @@ def create_aider_command(issue: str) -> list[str]:
return l
def get_commit_messages(cwd: Path, base_branch: str, current_branch: str) -> str:
"""Get commit messages between base branch and current branch.
Args:
cwd: The current working directory (repository path).
base_branch: The name of the base branch to compare against.
current_branch: The name of the current branch to check for commits.
Returns:
A string containing all commit messages, one per line.
"""
try:
result = subprocess.run(
['git', 'log', f'{base_branch}..{current_branch}', '--pretty=format:%s'],
check=True,
cwd=cwd,
capture_output=True,
text=True,
)
return result.stdout.strip()
except subprocess.CalledProcessError:
logger.exception(f'Failed to get commit messages on branch {current_branch}')
return ''
def push_changes(
cwd: Path,
branch_name: str,
@ -184,6 +210,16 @@ def push_changes(
if not has_commits_on_branch(cwd, base_branch, branch_name):
logger.info('No commits made on branch %s, skipping push', branch_name)
return False
# Get commit messages for PR description
commit_messages = get_commit_messages(cwd, base_branch, branch_name)
description = f'This pull request resolves #{issue_number}\n\n'
if commit_messages:
description += '## Commit Messages\n\n'
for message in commit_messages.split('\n'):
description += f'- {message}\n'
cmd = [
'git',
'push',
@ -194,7 +230,7 @@ def push_changes(
'-o',
f'title={issue_title}',
'-o',
f'description=This pull request resolves #{issue_number}',
f'description={description}',
]
run_cmd(cmd, cwd)
return True

View File

@ -1,4 +1,3 @@
from aider_gitea.seen_issues_db import SeenIssuesDB