Simplify
This commit is contained in:
parent
07fca9b3c2
commit
903920bdfd
|
@ -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', '<br>')
|
||||
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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user