diff --git a/aider_gitea/__init__.py b/aider_gitea/__init__.py index 92d34a3..1c300ee 100644 --- a/aider_gitea/__init__.py +++ b/aider_gitea/__init__.py @@ -174,7 +174,7 @@ def create_aider_command(issue: str) -> list[str]: return l -def get_commit_messages(cwd: Path, base_branch: str, current_branch: str) -> str: +def get_commit_messages(cwd: Path, base_branch: str, current_branch: str) -> list[str]: """Get commit messages between base branch and current branch. Args: @@ -193,7 +193,7 @@ def get_commit_messages(cwd: Path, base_branch: str, current_branch: str) -> str capture_output=True, text=True, ) - return result.stdout.strip() + return reversed(result.stdout.strip().split('\n')) except subprocess.CalledProcessError: logger.exception(f'Failed to get commit messages on branch {current_branch}') return '' @@ -220,11 +220,11 @@ def push_changes( if commit_messages: description += '## Commit Messages\n\n' - for message in commit_messages.split('\n'): + for message in commit_messages: description += f'- {message}\n' # First push the branch without creating a PR - cmd = ['git', 'push', 'origin', branch_name] + cmd = ['git', 'push', 'origin', branch_name, '--force'] run_cmd(cmd, cwd) # Then create the PR with the aider label