コード例 #1
0
def start_pr_release(repo_full_name, pr_number, pr_title, comment):
    tag = 'pull_request_merger'
    pr_templates = templateApi.getTemplates(tag)
    if not pr_templates:
        template_id = GitHubUtils.bootstrapPRMergerTemplate()
    else:
        if len(pr_templates) > 1:
            logger.warn("Found more than one template with tag '%s', using the first one" % tag)
        template_id = pr_templates[0].id

    params = StartRelease()
    params.setReleaseTitle('Merge PR #%s: %s' % (pr_number, pr_title))
    variables = HashMap()
    variables.put('${pull_request_number}', '%s' % pr_number)
    variables.put('${pull_request_title}', '%s' % pr_title)
    variables.put('${repository_full_name}', '%s' % repo_full_name)
    variables.put('${pull_request_comment}', '%s' % comment)
    params.setReleaseVariables(variables)
    started_release = templateApi.start(template_id, params)
    response.entity = started_release
    logger.info("Started release %s to merge pull request %s" % (started_release.getId(), pr_number))
コード例 #2
0
def start_pr_release(repo_full_name, pr_number, pr_title, comment):
    tag = 'pull_request_merger'
    pr_templates = templateApi.getTemplates(tag)
    if not pr_templates:
        template_id = GitHubUtils.bootstrapPRMergerTemplate()
    else:
        if len(pr_templates) > 1:
            logger.warn(
                "Found more than one template with tag '%s', using the first one"
                % tag)
        template_id = pr_templates[0].id

    params = StartRelease()
    params.setReleaseTitle('Merge PR #%s: %s' % (pr_number, pr_title))
    variables = HashMap()
    variables.put('${pull_request_number}', '%s' % pr_number)
    variables.put('${pull_request_title}', '%s' % pr_title)
    variables.put('${repository_full_name}', '%s' % repo_full_name)
    variables.put('${pull_request_comment}', '%s' % comment)
    params.setReleaseVariables(variables)
    started_release = templateApi.start(template_id, params)
    response.entity = started_release
    logger.info("Started release %s to merge pull request %s" %
                (started_release.getId(), pr_number))
コード例 #3
0
from com.xebialabs.xlrelease.plugin.github import GitHubUtils
from org.eclipse.egit.github.core.service import PullRequestService

pull_request_number = int("""${pull_request_number}""")
repository_full_name = """${repository_full_name}"""

github_client = GitHubUtils.getGitHubClient(repository_full_name)
repository = GitHubUtils.createRepositoryId(repository_full_name)
pr_service = PullRequestService(github_client)

pr = pr_service.getPullRequest(repository, pull_request_number)

if pr.getHead().getRef() != 'master':
    github_client.delete('/repos/%s/git/refs/heads/%s' % (repository_full_name, pr.getHead().getRef()))
else:
    logger.info("Don't ask me to delete 'master' branch!")
コード例 #4
0
import sys
from com.xebialabs.xlrelease.plugin.github import GitHubUtils
from org.eclipse.egit.github.core.service import PullRequestService
from org.eclipse.egit.github.core.service import IssueService

pull_request_number = int("""${pull_request_number}""")
pull_request_title = """${pull_request_title}"""
repository_full_name = """${repository_full_name}"""
pull_request_comment = """${pull_request_comment}"""

github_client = GitHubUtils.getGitHubClient(repository_full_name)
repository = GitHubUtils.createRepositoryId(repository_full_name)
issue_service = IssueService(github_client)
pr_service = PullRequestService(github_client)


def cancel_release(message):
    logger.info('Creating a comment on PR #%s: "%s"' %
                (pull_request_number, message))
    issue_service.createComment(repository, pull_request_number, message)
    sys.exit(1)


if 'squash' not in pull_request_comment:
    cancel_release(
        "I don't understand what you ask me. Did you mean 'xlr: squash this'?")

pr = pr_service.getPullRequest(repository, pull_request_number)
if not pr.isMergeable():
    cancel_release("This pull request is not automatically mergeable")