Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_url_is_downstream():
c = get_test_config()
api = get_packit_api(
config=c,
local_project=LocalProject(git_url="https://src.fedoraproject.org/rpms/packit"),
)
assert api.downstream_local_project
assert not api.upstream_local_project
def test_get_api(tmp_path, remotes, package_config, is_upstream):
repo = tmp_path / "project_repo"
repo.mkdir(parents=True, exist_ok=True)
initiate_git_repo(repo, remotes=remotes)
flexmock(utils).should_receive("get_local_package_config").and_return(
package_config
)
c = get_test_config()
api = get_packit_api(config=c, local_project=LocalProject(working_dir=str(repo)))
if is_upstream:
assert api.upstream_local_project
else:
flexmock(PackitAPI).should_receive("_run_kinit").once()
assert api.downstream_local_project
assert api.dg
def test_srpm_on_example(example_repo):
c = get_test_config()
api = get_packit_api(
config=c, local_project=LocalProject(working_dir=str(example_repo))
)
with cwd(example_repo):
path = api.create_srpm()
assert path.exists()
build_srpm(path)
def test_is_upstream(upstream_and_remote):
upstream, _ = upstream_and_remote
c = get_test_config()
api = get_packit_api(
config=c, local_project=LocalProject(working_dir=str(upstream))
)
assert api.upstream_local_project
assert not api.downstream_local_project
assert api.upstream_local_project.working_dir == str(upstream)
path_or_url,
upstream_ref,
version,
remote, # click introspects this in LocalProjectParameter
force,
):
"""
Release current upstream release into Fedora
PATH_OR_URL argument is a local path or a URL to the upstream git repository,
it defaults to the current working directory
VERSION argument is optional, the latest upstream version
will be used by default
"""
api = get_packit_api(
config=config, dist_git_path=dist_git_path, local_project=path_or_url
)
branches_to_update = get_branches(*dist_git_branch.split(","), default="master")
click.echo(f"Syncing from the following branches: {', '.join(branches_to_update)}")
for branch in branches_to_update:
api.sync_release(
dist_git_branch=branch,
use_local_content=local_content,
version=version,
force_new_sources=force_new_sources,
upstream_ref=upstream_ref,
create_pr=not no_pr,
force=force,
)
dist_git_branch,
upstream_branch,
no_pr,
path_or_url,
fork,
remote,
exclude,
force,
):
"""
Copy synced files from Fedora dist-git into upstream by opening a pull request.
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)
branches_to_sync = get_branches(*dist_git_branch.split(","), default="master")
click.echo(f"Syncing from the following branches: {', '.join(branches_to_sync)}")
for branch in branches_to_sync:
api.sync_from_downstream(
dist_git_branch=branch,
upstream_branch=upstream_branch,
no_pr=no_pr,
fork=fork,
remote_name=remote,
exclude_files=exclude,
force=force,
)
def create_update(
config, dist_git_branch, koji_build, update_notes, update_type, path_or_url
):
"""
Create a bodhi update for the selected upstream project
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)
branches_to_update = get_branches(*dist_git_branch.split(","), default="master")
click.echo(f"Syncing from the following branches: {', '.join(branches_to_update)}")
for branch in branches_to_update:
api.create_update(
koji_builds=koji_build,
dist_git_branch=branch,
update_notes=update_notes,
update_type=update_type,
)
def local_build(config, path_or_url, upstream_ref, remote):
"""
Create RPMs using content of the upstream repository.
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)
rpm_paths = api.create_rpms(upstream_ref=upstream_ref)
logger.info("RPMs:")
for path in rpm_paths:
logger.info(f" * {path}")
def status(config, path_or_url):
"""
Display status.
\b
- latest downstream pull requests
- versions from all downstream branches
- latest upstream releases
- latest builds in Koji
- latest builds in Copr
- latest updates in Bodhi
"""
api = get_packit_api(config=config, local_project=path_or_url)
api.status()
def push_updates(update_alias, config, path_or_url):
"""
Find all Bodhi updates that have been in testing for more than 'Stable days' (7 by default)
and push them to stable.
"""
api = get_packit_api(config=config, local_project=path_or_url)
api.push_updates(update_alias)