Skip to content

Commit

Permalink
Fix boolean error in warning; error out if only one of --version an…
Browse files Browse the repository at this point in the history
…d `--codename` is supplied for an ansible-core release (#105)

* Fix boolean error.

* Don't ignore --version or --codename when only one is supplied for an ansible-core release.

* Remove unnecessary pylint ignore.

Relates: #104
  • Loading branch information
felixfontein authored Mar 13, 2023
1 parent 5760deb commit 2451c2d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/105-version-codename.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "When releasing ansible-core and only one of ``--version`` and ``--codename`` is supplied, error out instead of ignoring the supplied value (https://github.com/ansible-community/antsibull-changelog/issues/104, https://github.com/ansible-community/antsibull-changelog/pull/105)."
8 changes: 7 additions & 1 deletion src/antsibull_changelog/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def set_paths(force: str | None = None,
raise ChangelogError( # pylint: disable=raise-missing-from
"Only the 'init' command can be used outside an Ansible checkout and outside a "
"collection repository, or inside one without changelogs/config.yaml.\n"
"If you are in a collection without galaxy.yml, specify `--is-collection no` "
"If you are in a collection without galaxy.yml, specify `--is-collection yes` "
"on the command line.")


Expand Down Expand Up @@ -486,6 +486,12 @@ def _get_version_and_codename(paths: PathsConfig, config: ChangelogConfig,
codename: str | None = args.codename

if not config.is_collection and not config.is_other_project and not (version and codename):
if version or codename:
# Only one is supplied: error out instead of simply ignoring that one
raise ChangelogError(
'For ansible-core releases both --version and --codename must be supplied if at'
' least one of them has been supplied'
)
# Both version and codename are required for ansible-core
try:
return get_ansible_release()
Expand Down

0 comments on commit 2451c2d

Please sign in to comment.