def gh_merge_do(owner, repo, pr_id): import github user = github.user_from_oauth(bottle.request.oauth_token) pr = github.get_pull_request(owner, repo, pr_id) if 'login' not in user: raise bottle.HTTPError(403, 'Could not identify user') if 'user' not in pr: raise bottle.HTTPError(403, 'Could not identify PR') if user['login'] != pr['user']['login']: raise bottle.HTTPError(403, 'Merge requester is not the PR author') if pr['merged']: raise bottle.HTTPError(403, 'PR is already merged') if not pr['mergeable']: raise bottle.HTTPError(403, 'PR cannot be merged. Please rebase') if not github.is_pull_request_buildable(pr): raise bottle.HTTPError(403, 'PR status not green. Wait or fix errors') if not github.is_pull_request_self_mergeable(pr): raise bottle.HTTPError(403, 'Nobody allowed you to merge this PR') github.merge_pr(pr) bottle.redirect(pr['html_url'])
def gh_merge_do(owner, repo, pr_id): import github user = github.user_from_oauth(bottle.request.oauth_token) pr = github.get_pull_request(owner, repo, pr_id) if "login" not in user: raise bottle.HTTPError(403, "Could not identify user") if "user" not in pr: raise bottle.HTTPError(403, "Could not identify PR") if user["login"] != pr["user"]["login"]: raise bottle.HTTPError(403, "Merge requester is not the PR author") if pr["merged"]: raise bottle.HTTPError(403, "PR is already merged") if not pr["mergeable"]: raise bottle.HTTPError(403, "PR cannot be merged. Please rebase") if not github.is_pull_request_buildable(pr): raise bottle.HTTPError(403, "PR status not green. Wait or fix errors") if not github.is_pull_request_self_mergeable(pr): raise bottle.HTTPError(403, "Nobody allowed you to merge this PR") github.merge_pr(pr) bottle.redirect(pr["html_url"])