예제 #1
0
def test_sanitize_branch(inp, exp, exp_rpm):
    assert sanitize_branch_name(inp) == exp
    assert sanitize_branch_name_for_rpm(inp) == exp_rpm
예제 #2
0
파일: copr_build.py 프로젝트: packit/packit
def copr_build(
    config,
    nowait,
    owner,
    project,
    targets,
    description,
    instructions,
    list_on_homepage,
    preserve_project,
    upstream_ref,
    additional_repos,
    request_admin_if_needed,
    path_or_url,
):
    """
    Build selected upstream project in COPR.

    PATH_OR_URL argument is a local path or a URL to the upstream git repository,
    it defaults to the current working directory.
    """
    api = get_packit_api(config=config, local_project=path_or_url)
    if not project:
        logger.debug("COPR project name was not passed via CLI.")

        if isinstance(api.package_config, PackageConfig):
            project = api.package_config.get_copr_build_project_value()

        if project:
            logger.debug(
                "Using a first COPR project found in the job configuration.")
        else:
            logger.debug("COPR project not found in the job configuration. "
                         "Using the default one.")
            sanitized_ref = sanitize_branch_name(path_or_url.ref)
            project = f"packit-cli-{path_or_url.repo_name}-{sanitized_ref}"

    logger.info(f"Using COPR project name = {project}")

    targets_list = targets.split(",")
    for target in targets_list:
        if target in DEPRECATED_TARGET_MAP:
            logger.warning(
                f"Target '{target}' is deprecated. "
                f"Please use '{DEPRECATED_TARGET_MAP[target]}' instead.")
    targets_to_build = get_valid_build_targets(*targets_list,
                                               default="fedora-rawhide-x86_64")

    logger.info(f"Targets to build: {targets_to_build}.")

    additional_repos_list: Optional[List[str]] = (
        additional_repos.split(",") if additional_repos else None)

    build_id, repo_url = api.run_copr_build(
        project=project,
        chroots=list(targets_to_build),
        owner=owner,
        description=description,
        instructions=instructions,
        upstream_ref=upstream_ref,
        list_on_homepage=list_on_homepage,
        preserve_project=preserve_project,
        additional_repos=additional_repos_list,
        request_admin_if_needed=request_admin_if_needed,
    )
    click.echo(f"Build id: {build_id}, repo url: {repo_url}")
    if not nowait:
        api.watch_copr_build(build_id=build_id, timeout=60 * 60 * 2)