Skip to content

Commit

Permalink
CLI: deprecate --[no-]bump in favour of --[no-]update-release
Browse files Browse the repository at this point in the history
  • Loading branch information
jpopelka committed Jan 17, 2023
1 parent b7d3290 commit 8338666
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
17 changes: 15 additions & 2 deletions packit/cli/prepare_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,18 @@ def load_job_config(job_config):
"(this option implies the repository is source-git).",
)
@click.option(
"--bump/--no-bump",
"--update-release/--no-update-release",
default=None,
help=(
"Specifies whether to update Version and Release. "
"Defaults to value set in configuration, which defaults to yes."
),
)
@click.option(
"--bump/--no-bump",
default=None,
help="Deprecated. Use --[no-]update-release instead.",
)
@click.option(
"--release-suffix",
default=None,
Expand Down Expand Up @@ -117,6 +122,7 @@ def prepare_sources(
path_or_url,
job_config_index,
upstream_ref,
update_release,
bump,
release_suffix,
default_release_suffix,
Expand Down Expand Up @@ -144,13 +150,20 @@ def prepare_sources(
api = get_packit_api(
config=config, local_project=path_or_url, job_config_index=job_config_index
)
if bump is not None:
if update_release is not None:
raise click.UsageError(
"--[no-]bump and --[no-]update-release are mutually exclusive"
)
logger.warning("--[no-]bump is deprecated. Use --[no-]update-release instead.")
update_release = bump
release_suffix = ChangelogHelper.resolve_release_suffix(
api.package_config, release_suffix, default_release_suffix
)

api.prepare_sources(
upstream_ref=upstream_ref,
update_release=bump,
update_release=update_release,
release_suffix=release_suffix,
result_dir=result_dir,
create_symlinks=create_symlinks,
Expand Down
17 changes: 15 additions & 2 deletions packit/cli/srpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@
"(this option implies the repository is source-git).",
)
@click.option(
"--bump/--no-bump",
"--update-release/--no-update-release",
default=None,
help=(
"Specifies whether to update Version and Release. "
"Defaults to value set in configuration, which defaults to yes."
),
)
@click.option(
"--bump/--no-bump",
default=None,
help="Deprecated. Use --[no-]update-release instead.",
)
@click.option(
"--release-suffix",
default=None,
Expand Down Expand Up @@ -61,6 +66,7 @@ def srpm(
output,
path_or_url,
upstream_ref,
update_release,
bump,
release_suffix,
default_release_suffix,
Expand All @@ -72,6 +78,13 @@ def srpm(
it defaults to the current working directory
"""
api = get_packit_api(config=config, local_project=path_or_url)
if bump is not None:
if update_release is not None:
raise click.UsageError(
"--[no-]bump and --[no-]update-release are mutually exclusive"
)
logger.warning("--[no-]bump is deprecated. Use --[no-]update-release instead.")
update_release = bump
release_suffix = ChangelogHelper.resolve_release_suffix(
api.package_config,
release_suffix,
Expand All @@ -81,7 +94,7 @@ def srpm(
srpm_path = api.create_srpm(
output_file=output,
upstream_ref=upstream_ref,
update_release=bump,
update_release=update_release,
release_suffix=release_suffix,
)
logger.info(f"SRPM: {srpm_path}")
2 changes: 1 addition & 1 deletion packit/utils/source_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def create_source_script(
if job_config_index is not None:
options += ["--job-config-index", str(job_config_index)]
if not update_release:
options += ["--no-bump"]
options += ["--no-update-release"]
if release_suffix:
options += ["--release-suffix", f"'{release_suffix}'"]

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_upstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def test_get_srpm_from_rpmbuild_output(upstream_mock, rpmbuild_output):
pytest.param(
True,
"",
# bump_version from command line wins over release_suffix on packit.yaml
# update-release from command line wins over release_suffix on packit.yaml
"2.1234.mock_ref.",
id="Bump release, release_suffix is empty",
),
Expand Down Expand Up @@ -454,7 +454,7 @@ def test_get_spec_release(
pytest.param(
True,
"",
# bump_version from command line wins over release_suffix on packit.yaml
# update-release from command line wins over release_suffix on packit.yaml
"2.1234.mock_ref.",
id="Bump release, release_suffix is empty",
),
Expand Down

0 comments on commit 8338666

Please sign in to comment.