Simplify
This commit is contained in:
parent
07fca9b3c2
commit
903920bdfd
|
@ -205,9 +205,9 @@ def push_changes(
|
||||||
issue_number: str,
|
issue_number: str,
|
||||||
issue_title: str,
|
issue_title: str,
|
||||||
base_branch: str,
|
base_branch: str,
|
||||||
gitea_client=None,
|
gitea_client,
|
||||||
owner=None,
|
owner: str,
|
||||||
repo=None,
|
repo: str,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
# Check if there are any commits on the branch before pushing
|
# Check if there are any commits on the branch before pushing
|
||||||
if not has_commits_on_branch(cwd, base_branch, branch_name):
|
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'):
|
for message in commit_messages.split('\n'):
|
||||||
description += f'- {message}\n'
|
description += f'- {message}\n'
|
||||||
|
|
||||||
# If we have a Gitea client, create the PR with the aider label
|
# First push the branch without creating a PR
|
||||||
if gitea_client and owner and repo:
|
cmd = ['git', 'push', 'origin', branch_name]
|
||||||
# First push the branch without creating a PR
|
run_cmd(cmd, cwd)
|
||||||
cmd = ['git', 'push', 'origin', branch_name]
|
|
||||||
run_cmd(cmd, cwd)
|
|
||||||
|
|
||||||
# Then create the PR with the aider label
|
# Then create the PR with the aider label
|
||||||
gitea_client.create_pull_request(
|
gitea_client.create_pull_request(
|
||||||
owner=owner,
|
owner=owner,
|
||||||
repo=repo,
|
repo=repo,
|
||||||
title=issue_title,
|
title=issue_title,
|
||||||
body=description,
|
body=description,
|
||||||
head=branch_name,
|
head=branch_name,
|
||||||
base=base_branch,
|
base=base_branch,
|
||||||
labels=['aider'],
|
labels=['aider'],
|
||||||
)
|
)
|
||||||
return True
|
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
|
|
||||||
|
|
||||||
|
|
||||||
def has_commits_on_branch(cwd: Path, base_branch: str, current_branch: str) -> bool:
|
def has_commits_on_branch(cwd: Path, base_branch: str, current_branch: str) -> bool:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user