Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix check for output format #151

Merged
merged 3 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/151-generate-output-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "When multiple output formats are defined and ``antsibull-changelog generate`` is used with both ``--output`` and ``--output-format``, an error was displayed that ``--output-format`` must be specified (https://github.com/ansible-community/antsibull-changelog/issues/149, https://github.com/ansible-community/antsibull-changelog/pull/151)."
2 changes: 1 addition & 1 deletion src/antsibull_changelog/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ def command_generate(args: Any) -> int: # pylint: disable=too-many-locals
version=changes.latest_version,
force_reload=args.reload_plugins,
)
if output and len(config.output_formats) > 1:
if output and len(config.output_formats) > 1 and not output_format:
print(
"When an explicit output path is specified and more than one output format"
" is configured, you need to explicitly specify an output format"
Expand Down
31 changes: 31 additions & 0 deletions tests/functional/test_changelog_basic_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,37 @@ def test_changelog_release_empty( # pylint: disable=redefined-outer-name
)
assert collection_changelog.diff().unchanged

assert (
collection_changelog.run_tool(
"generate",
["-v", "--refresh", "--output", "extract.md", "--output-format", "md"],
)
== 0
)

diff = collection_changelog.diff()
assert diff.added_dirs == []
assert diff.added_files == ["extract.md"]
assert diff.removed_dirs == []
assert diff.removed_files == []
assert diff.changed_files == []
assert diff.file_contents["extract.md"].decode("utf-8") == (
r"""# Ansible Release Notes

**Topics**
- <a href="#v1-0-0">v1\.0\.0</a>
- <a href="#release-summary">Release Summary</a>

<a id="v1-0-0"></a>
## v1\.0\.0

<a id="release-summary"></a>
### Release Summary

This is the first proper release\.
"""
)

assert (
collection_changelog.run_tool(
"release", ["-v", "--codename", "primetime", "--date", "2020-01-03"]
Expand Down
Loading