From 903920bdfdce46a0e0e95a049bbbb7920bf59854 Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Tue, 15 Apr 2025 00:26:23 +0200 Subject: [PATCH] Simplify --- aider_gitea/__init__.py | 53 +++++++++++++---------------------------- 1 file changed, 17 insertions(+), 36 deletions(-) diff --git a/aider_gitea/__init__.py b/aider_gitea/__init__.py index c78e0fb..92d34a3 100644 --- a/aider_gitea/__init__.py +++ b/aider_gitea/__init__.py @@ -205,9 +205,9 @@ def push_changes( issue_number: str, issue_title: str, base_branch: str, - gitea_client=None, - owner=None, - repo=None, + gitea_client, + owner: str, + repo: str, ) -> bool: # Check if there are any commits on the branch before pushing if not has_commits_on_branch(cwd, base_branch, branch_name): @@ -223,40 +223,21 @@ def push_changes( for message in commit_messages.split('\n'): description += f'- {message}\n' - # If we have a Gitea client, create the PR with the aider label - if gitea_client and owner and repo: - # First push the branch without creating a PR - cmd = ['git', 'push', 'origin', branch_name] - run_cmd(cmd, cwd) + # First push the branch without creating a PR + cmd = ['git', 'push', 'origin', branch_name] + run_cmd(cmd, cwd) - # Then create the PR with the aider label - gitea_client.create_pull_request( - owner=owner, - repo=repo, - title=issue_title, - body=description, - head=branch_name, - base=base_branch, - labels=['aider'], - ) - return True - else: - # Fall back to the original method if no Gitea client is provided - description_formatted = description.replace('\n', '
') - cmd = [ - 'git', - 'push', - 'origin', - f'HEAD:refs/for/{base_branch}', - '-o', - f'topic={branch_name}', - '-o', - f'title={issue_title}', - '-o', - f'description="{description_formatted}"', - ] - run_cmd(cmd, cwd) - return True + # Then create the PR with the aider label + gitea_client.create_pull_request( + owner=owner, + repo=repo, + title=issue_title, + body=description, + head=branch_name, + base=base_branch, + labels=['aider'], + ) + return True def has_commits_on_branch(cwd: Path, base_branch: str, current_branch: str) -> bool: