How to use the packit.config.SyncFilesConfig function in packit

To help you get started, we’ve selected a few packit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github packit-service / packit / tests / unit / test_package_config.py View on Github external
pc = PackageConfig(
        dist_git_base_url="https://packit.dev/",
        downstream_package_name="packit",
        dist_git_namespace="awesome",
        synced_files=SyncFilesConfig(
            files_to_sync=[
                SyncFilesItem(src="fedora/foobar.spec", dest="fedora/foobar.spec")
            ]
        ),
        specfile_path="fedora/package.spec",
        create_pr=False,
        jobs=get_default_job_config(
            dist_git_base_url="https://packit.dev/",
            downstream_package_name="packit",
            dist_git_namespace="awesome",
            synced_files=SyncFilesConfig(
                files_to_sync=[
                    SyncFilesItem(src="fedora/foobar.spec", dest="fedora/foobar.spec")
                ]
            ),
            specfile_path="fedora/package.spec",
            create_pr=False,
        ),
    )
    assert new_pc.specfile_path.endswith("fedora/package.spec")
    assert pc.specfile_path.endswith("fedora/package.spec")
    assert pc == new_pc
    assert pc.dist_git_package_url == "https://packit.dev/awesome/packit.git"
    assert new_pc.dist_git_package_url == "https://packit.dev/awesome/packit.git"
    assert not pc.create_pr
github packit-service / packit / tests / unit / test_package_config.py View on Github external
            SyncFilesConfig(
                files_to_sync=[
                    SyncFilesItem(src="file.spec", dest="file.spec"),
                    SyncFilesItem(src="packit.yaml", dest="packit.yaml"),
                ]
            ),
        ),
        (
            PackageConfig(
                config_file_path="packit.yaml",
                specfile_path="file.spec",
                synced_files=SyncFilesConfig(
                    files_to_sync=[SyncFilesItem(src="file.txt", dest="file.txt")]
                ),
            ),
            SyncFilesConfig(
                files_to_sync=[
github packit-service / packit / tests / integration / test_sync_files.py View on Github external
            SyncFilesConfig(
                files_to_sync=[SyncFilesItem(src="example_dir/*.md", dest="tests/")]
            ),
            [
                RawSyncFilesItem(Path("example_dir/d.md"), Path("tests"), True),
                RawSyncFilesItem(Path("example_dir/e.md"), Path("tests"), True),
            ],
        ),
        (
            SyncFilesConfig(
                files_to_sync=[SyncFilesItem(src="example_dir/e*d", dest="example")]
            ),
            [RawSyncFilesItem(Path("example_dir/e.md"), Path("example"), False)],
        ),
        (
            SyncFilesConfig(
                files_to_sync=[
github packit-service / packit / tests / unit / test_package_config.py View on Github external
def test_package_config_equal(job_config_simple):
    assert PackageConfig(
        specfile_path="fedora/package.spec",
        synced_files=SyncFilesConfig(
            files_to_sync=[SyncFilesItem(src="packit.yaml", dest="packit.yaml")]
        ),
        jobs=[job_config_simple],
        downstream_package_name="package",
        create_pr=True,
    ) == PackageConfig(
        specfile_path="fedora/package.spec",
        synced_files=SyncFilesConfig(
            files_to_sync=[SyncFilesItem(src="packit.yaml", dest="packit.yaml")]
        ),
        jobs=[job_config_simple],
        downstream_package_name="package",
        create_pr=True,
    )
github packit-service / packit / tests / unit / test_package_config.py View on Github external
project: GitProject,
    mock_spec_search: bool,
    spec_path: Optional[str],
    spec_path_option: Optional[str],
):
    gp = flexmock(GitProject)
    gp.should_receive("full_repo_name").and_return("a/b")
    gp.should_receive("get_file_content").and_return(content)
    if mock_spec_search:
        gp.should_receive("get_files").and_return(["packit.spec"]).once()
    config = get_package_config_from_repo(
        project=project, ref="", spec_file_path=spec_path_option
    )
    assert isinstance(config, PackageConfig)
    assert config.specfile_path == spec_path
    assert config.synced_files == SyncFilesConfig(
        files_to_sync=[
            SyncFilesItem(src="packit.spec", dest="packit.spec"),
            SyncFilesItem(src=".packit.yaml", dest=".packit2.yaml"),
        ]
    )
    assert config.create_pr
github packit-service / packit / tests / unit / test_package_config.py View on Github external
            synced_files=SyncFilesConfig(
                files_to_sync=[
                    SyncFilesItem(src="fedora/package.spec", dest="fedora/package.spec")
                ]
            ),
        ),
        PackageConfig(
            specfile_path="fedora/package.spec",
            downstream_package_name="package",
            synced_files=SyncFilesConfig(
                files_to_sync=[
                    SyncFilesItem(src="fedora/package.spec", dest="fedora/package.spec")
                ]
            ),
            jobs=[
                get_job_config_full(
                    specfile_path="fedora/package.spec",
github packit-service / packit / packit / config.py View on Github external
def get_from_dict(cls, raw_dict: dict, validate=True) -> "SyncFilesConfig":
        if validate:
            cls.validate(raw_dict)

        files_to_sync = []
        if isinstance(raw_dict, list):
            for f in raw_dict:
                if isinstance(f, dict):
                    files_to_sync.append(SyncFilesItem(src=f["src"], dest=f["dest"]))
                else:
                    files_to_sync.append(SyncFilesItem(src=f, dest=f))
        if isinstance(raw_dict, dict):
            for f in raw_dict:
                files_to_sync.append(SyncFilesItem(src=f["src"], dest=f["dest"]))

        return SyncFilesConfig(files_to_sync=files_to_sync)
github packit-service / packit / packit / config.py View on Github external
upstream_project_url: str = None,  # can be URL or path
        upstream_package_name: str = None,
        downstream_project_url: str = None,
        downstream_package_name: str = None,
        dist_git_base_url: str = None,
        create_tarball_command: List[str] = None,
        current_version_command: List[str] = None,
        actions: Dict[ActionName, Union[str, List[str]]] = None,
        upstream_ref: Optional[str] = None,
        allowed_gpg_keys: Optional[List[str]] = None,
        create_pr: bool = False,
        spec_source_id: str = "Source0",
        upstream_tag_template: str = "{version}",
    ):
        self.specfile_path: Optional[str] = specfile_path
        self.synced_files: SyncFilesConfig = synced_files or SyncFilesConfig([])
        self.jobs: List[JobConfig] = jobs or []
        self.dist_git_namespace: str = dist_git_namespace or "rpms"
        self.upstream_project_url: Optional[str] = upstream_project_url
        self.upstream_package_name: Optional[str] = upstream_package_name
        # this is generated by us
        self._downstream_package_name: Optional[str] = downstream_package_name
        self.dist_git_base_url: str = dist_git_base_url or PROD_DISTGIT_URL
        self._downstream_project_url: str = downstream_project_url
        # path to a local git clone of the dist-git repo; None means to clone in a tmpdir
        self.dist_git_clone_path: Optional[str] = None
        self.actions = actions or {}
        self.upstream_ref: Optional[str] = upstream_ref
        self.allowed_gpg_keys = allowed_gpg_keys
        self.create_pr: bool = create_pr
        self.spec_source_id: str = spec_source_id
github packit-service / packit / packit / schema.py View on Github external
def make_instance(self, data, **kwargs):
        return SyncFilesConfig(**data)
github packit-service / packit / packit / config.py View on Github external
upstream_tag_template = raw_dict.get("upstream_tag_template", "{version}")

        # it can be int as well
        spec_source_id = raw_dict.get("spec_source_id", "Source0")
        try:
            spec_source_id = int(spec_source_id)
        except ValueError:
            # not a number
            pass
        else:
            # is a number!
            spec_source_id = f"Source{spec_source_id}"

        pc = PackageConfig(
            specfile_path=specfile_path,
            synced_files=SyncFilesConfig.get_from_dict(synced_files, validate=False),
            actions={ActionName(a): cmd for a, cmd in actions.items()},
            jobs=[
                JobConfig.get_from_dict(raw_job, validate=False) for raw_job in raw_jobs
            ],
            upstream_package_name=upstream_package_name,
            downstream_package_name=downstream_package_name,
            upstream_project_url=upstream_project_url,
            dist_git_base_url=dist_git_base_url,
            dist_git_namespace=dist_git_namespace,
            create_tarball_command=create_tarball_command,
            current_version_command=current_version_command,
            upstream_ref=upstream_ref,
            allowed_gpg_keys=allowed_gpg_keys,
            create_pr=create_pr,
            spec_source_id=spec_source_id,
            upstream_tag_template=upstream_tag_template,