Beispiel #1
0
def create_pr(target_remote, target_branch):
    """
    Create a pull or a merge request against upstream remote.

    The default projects's branch is used implicitly
    (which everyone can configure in their project settings).
    """
    app = App()

    url = app.guess_remote_url()
    git_project = app.get_git_project(url)

    username = git_project.service.user.get_username()

    if not target_branch:
        target_branch = git_project.default_branch
        logger.info(f"Branch not specified, using {target_branch}.")

    base = "{}/{}".format(target_remote, target_branch)

    git_push()

    title, body = prompt_for_pr_content(get_commit_msgs(base))

    pr = git_project.create_pr(title,
                               body,
                               target_branch,
                               app.get_current_branch(),
                               fork_username=username)

    logger.info("PR link: %s", pr.url)
    print(pr.url)
Beispiel #2
0
def create_pr(target_remote, target_branch):
    """
    Fork selected repository
    """
    a = App()
    s = a.guess_service(remote=target_remote)
    pr_url = s.create_pull_request(target_remote, target_branch, a.get_current_branch())
    print(pr_url)
Beispiel #3
0
def create_pr(target_remote, target_branch):
    """
    Create a pull or a merge request against upstream remote.

    The default projects's branch is used implicitly
    (which everyone can configure in their project settings).
    """
    app = App()

    url = app.guess_remote_url()
    git_project = app.get_git_project(url)

    username = git_project.service.user.get_username()

    if not target_branch:
        target_branch = git_project.default_branch
        logger.info(f"Branch not specified, using {target_branch}.")

    base = "{}/{}".format(target_remote, target_branch)

    git_push()

    commit_msgs = get_commit_msgs(base)
    project_pr_template = None
    if "github.com" in git_project.get_web_url():
        try:
            project_pr_template = git_project.get_file_content(
                ".github/PULL_REQUEST_TEMPLATE.md"
            )
        except FileNotFoundError:
            logger.debug("No PR template found.")
    template = assemble_pr_template(
        commit_msgs, project_pr_template=project_pr_template
    )

    title, body = prompt_for_pr_content(template)

    pr = git_project.create_pr(
        title, body, target_branch, app.get_current_branch(), fork_username=username
    )

    logger.info("PR link: %s", pr.url)
    print(pr.url)