From 77ce2da456dc321ef55653dc2051970a224b0db2 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 27 Oct 2024 09:02:05 +0100 Subject: [PATCH 1/2] Fix namespace extraction for ansible-core modules. --- changelogs/fragments/185-core-modules.yml | 2 ++ src/antsibull_changelog/plugins.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/185-core-modules.yml diff --git a/changelogs/fragments/185-core-modules.yml b/changelogs/fragments/185-core-modules.yml new file mode 100644 index 00000000..456adcd1 --- /dev/null +++ b/changelogs/fragments/185-core-modules.yml @@ -0,0 +1,2 @@ +bugfixes: + - "Fix ``namespace`` extraction for ansible-core modules (https://github.com/ansible-community/antsibull-changelog/issues/184, https://github.com/ansible-community/antsibull-changelog/pull/185)." diff --git a/src/antsibull_changelog/plugins.py b/src/antsibull_changelog/plugins.py index b71d3325..0d110c5b 100644 --- a/src/antsibull_changelog/plugins.py +++ b/src/antsibull_changelog/plugins.py @@ -112,7 +112,7 @@ def extract_namespace( # Follow links filename = os.path.realpath(filename) # Determine relative path - if collection_name: + if collection_name and collection_name != "ansible.builtin": rel_to = os.path.join(paths.base_dir, "plugins", "modules") else: rel_to = os.path.join(paths.base_dir, "lib", "ansible", "modules") From 130e7f3225a4c1a9da055a53269c8e61d24de397 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 27 Oct 2024 09:06:44 +0100 Subject: [PATCH 2/2] Make sure the correct code-path is used for ansible-core 2.13+ output, and fix codepath. --- src/antsibull_changelog/plugins.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/antsibull_changelog/plugins.py b/src/antsibull_changelog/plugins.py index 0d110c5b..9369cf70 100644 --- a/src/antsibull_changelog/plugins.py +++ b/src/antsibull_changelog/plugins.py @@ -112,7 +112,7 @@ def extract_namespace( # Follow links filename = os.path.realpath(filename) # Determine relative path - if collection_name and collection_name != "ansible.builtin": + if collection_name: rel_to = os.path.join(paths.base_dir, "plugins", "modules") else: rel_to = os.path.join(paths.base_dir, "lib", "ansible", "modules") @@ -159,7 +159,7 @@ def jsondoc_to_metadata( # pylint: disable=too-many-arguments docs = entrypoints["main"] if category == "plugin" and plugin_type == "module": if is_ansible_core_2_13: - last_dot = name.rindex(".") + last_dot = name.rfind(".") if last_dot >= 0: namespace = name[:last_dot] name = name[last_dot + 1 :] @@ -400,6 +400,7 @@ def _load_plugins_2_13( plugin_name, plugin_data, category=category[:-1], + is_ansible_core_2_13=True, ) plugins_data[category][plugin_type][ processed_data["name"]