1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-08-20 21:48:53 +02:00
Files

45 lines
1.1 KiB
Python

import osc.commandline_git
class PullRequestMergeCommand(osc.commandline_git.GitObsCommand):
"""
Merge pull requests
"""
name = "merge"
parent = "PullRequestCommand"
def init_arguments(self):
self.add_argument(
"id",
nargs="+",
help="Pull request ID in <owner>/<repo>#<number> format",
)
self.add_argument(
"--now",
action="store_true",
help="Merge immediately, don't wait until all checks succeed.",
)
def run(self, args):
from osc import gitea_api
self.print_gitea_settings()
pull_request_ids = args.id
for pr_index, pr_id in enumerate(pull_request_ids):
if args.now:
print(f"Merging {pr_id}...")
else:
print(f"Scheduling auto merge of {pr_id}...")
owner, repo, number = gitea_api.PullRequest.split_id(pr_id)
gitea_api.PullRequest.merge(
self.gitea_conn,
owner,
repo,
number,
merge_when_checks_succeed=not args.now,
)