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

add argument to update version in galaxy.yml file #127

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e13c18d
update basic changes
KB-perByte Jul 5, 2023
670c354
Update src/antsibull_changelog/update_galaxy.py
KB-perByte Jul 5, 2023
f3a6500
Update src/antsibull_changelog/update_galaxy.py
KB-perByte Jul 5, 2023
031c53a
update structure
KB-perByte Jul 5, 2023
1aed28d
make ci happy
KB-perByte Jul 5, 2023
397cdd7
Update src/antsibull_changelog/config.py
KB-perByte Jul 6, 2023
737b4b6
Update changelogs/fragments/update_galaxy.yaml
KB-perByte Jul 6, 2023
f1cad46
Update src/antsibull_changelog/cli.py
KB-perByte Jul 6, 2023
e8aaa90
Update src/antsibull_changelog/cli.py
KB-perByte Jul 6, 2023
39b0186
add review changes
KB-perByte Jul 18, 2023
745bfb0
fix lint
KB-perByte Jul 18, 2023
1cf39a0
Update src/antsibull_changelog/update_galaxy.py
KB-perByte Jul 19, 2023
bdec411
Update src/antsibull_changelog/update_galaxy.py
KB-perByte Jul 19, 2023
884fe25
Update src/antsibull_changelog/update_galaxy.py
KB-perByte Jul 19, 2023
e8e4484
update changes on comparison
KB-perByte Jul 19, 2023
cae00dc
update exceptions
KB-perByte Jul 19, 2023
a4d51e4
isort happy
KB-perByte Jul 19, 2023
abf9f7c
fix lint
KB-perByte Jul 19, 2023
5dbbb30
make conditional
KB-perByte Jul 19, 2023
813db15
refactor
KB-perByte Jul 19, 2023
35fe36e
Update src/antsibull_changelog/update_galaxy.py
KB-perByte Jul 19, 2023
649d53c
format return
KB-perByte Jul 19, 2023
bfda763
fix isort and lint
KB-perByte Jul 19, 2023
7be5797
Update src/antsibull_changelog/update_galaxy.py
KB-perByte Aug 3, 2023
87a686e
Update src/antsibull_changelog/cli.py
KB-perByte Aug 3, 2023
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
3 changes: 3 additions & 0 deletions changelogs/fragments/update_galaxy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- Add ``--update-galaxy-file`` option to the ``release`` command to update version in ``galaxy.yml`` file (https://github.com/ansible-community/antsibull-changelog/pull/127).
13 changes: 13 additions & 0 deletions src/antsibull_changelog/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from .logger import LOGGER, setup_logger
from .plugins import PluginDescription, load_plugins
from .toml import has_toml_loader_available, load_toml
from .update_galaxy import update_galaxy


def set_paths(
Expand Down Expand Up @@ -239,6 +240,12 @@ def create_argparser(program_name: str) -> argparse.ArgumentParser:
release_parser.set_defaults(func=command_release)
release_parser.add_argument("--version", help="override release version")
release_parser.add_argument("--codename", help="override/set release codename")
release_parser.add_argument(
"--update-galaxy-file",
action="store_true",
help="re-write galaxy.yml with the supplied version. "
"Note that this will remove comments and formatting",
)
release_parser.add_argument(
"--date", default=str(datetime.date.today()), help="override release date"
)
Expand Down Expand Up @@ -610,6 +617,12 @@ def command_release(args: Any) -> int:
paths, config, collection_details, args
)

if args.update_galaxy_file:
if not paths.galaxy_path:
LOGGER.error("Cannot find galaxy.yml file in path.")
KB-perByte marked this conversation as resolved.
Show resolved Hide resolved
else:
update_galaxy(galaxy_path=paths.galaxy_path, version=version)

changes = load_changes(config)

prev_version: str | None = None
Expand Down
34 changes: 34 additions & 0 deletions src/antsibull_changelog/update_galaxy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Author: Sagar Paul <paul.sagar@yahoo.com>
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or
# https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2023, Ansible Project

"""
Update the galaxy the yaml file.
"""

from __future__ import annotations

# from typing import TYPE_CHECKING

from .logger import LOGGER
from .yaml import load_yaml, store_yaml
KB-perByte marked this conversation as resolved.
Show resolved Hide resolved

# if TYPE_CHECKING:
# from _typeshed import StrOrBytesPath


def update_galaxy(galaxy_path: str, version: str) -> None:
KB-perByte marked this conversation as resolved.
Show resolved Hide resolved
"""
Load and update galaxy.yaml file.
"""
try:
config = load_yaml(galaxy_path)

if config["version"] != version:
KB-perByte marked this conversation as resolved.
Show resolved Hide resolved
config["version"] = version
store_yaml(galaxy_path, config)

except Exception: # pylint: disable=broad-except
LOGGER.error("Unable to load the galaxy.yml file.")
KB-perByte marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 15 additions & 0 deletions tests/units/fixtures/galaxy.yml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you added a fixture but didn't make any test changes?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't added any tests yet.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
authors:
- Ansible Bot (ansibuddy)
dependencies:
ansible.netcommon: ">=2.5.1"
description: Test dummy collection
issues: https://github.com/ansible-collections/test.dummy/issues
license_file: LICENSE
name: dummy
namespace: test
readme: README.md
repository: https://github.com/ansible-collections/test.dummy
tags:
- test
- dummy
version: 2.0.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file isn't used so far.

Loading