From 6164b4cbb18bc6df5eef384476b05ea79a148ff8 Mon Sep 17 00:00:00 2001 From: Johannes Rothe Date: Mon, 30 Jan 2023 10:27:23 +0100 Subject: [PATCH 1/2] Fix AttributeError with docutils >= 0.18 Closes #351 --- src/catkin_pkg/cli/tag_changelog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/catkin_pkg/cli/tag_changelog.py b/src/catkin_pkg/cli/tag_changelog.py index 311c7dba..f4fbb437 100644 --- a/src/catkin_pkg/cli/tag_changelog.py +++ b/src/catkin_pkg/cli/tag_changelog.py @@ -28,7 +28,7 @@ def get_forthcoming_label(rst): if len(section.children) > 0 and isinstance(section.children[0], docutils.nodes.title): title = section.children[0] if title and len(title.children) > 0 and isinstance(title.children[0], docutils.nodes.Text): - title_text = title.children[0].rawsource + title_text = title.children[0] if FORTHCOMING_LABEL.lower() in title_text.lower(): if forthcoming_label: raise RuntimeError('Found multiple forthcoming sections') From bfe0668583846c71f8ffc19dce35c5a57f620968 Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Wed, 8 Jan 2025 10:36:27 -0600 Subject: [PATCH 2/2] Add some basic tests for tag_changelog --- test/test_tag_changelog.py | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 test/test_tag_changelog.py diff --git a/test/test_tag_changelog.py b/test/test_tag_changelog.py new file mode 100644 index 00000000..a5b49c90 --- /dev/null +++ b/test/test_tag_changelog.py @@ -0,0 +1,43 @@ +# coding=utf-8 + +from catkin_pkg.cli.tag_changelog import get_forthcoming_label +from catkin_pkg.cli.tag_changelog import rename_section + +single_forthcoming_rst = """\ +^^^^^^^^^^^^^^^^^^^^^^^^^ +Changelog for package foo +^^^^^^^^^^^^^^^^^^^^^^^^^ + +Forthcoming +----------- + +* Initial release +* Initial bugs +* Contributors: Sömeöne with UTF-8 in their name +""" + +single_version_rst = """\ +^^^^^^^^^^^^^^^^^^^^^^^^^ +Changelog for package foo +^^^^^^^^^^^^^^^^^^^^^^^^^ + +0.0.1 (2012-01-31) +------------------ + +* Initial release +* Initial bugs +* Contributors: Sömeöne with UTF-8 in their name +""" + + +def test_get_forthcoming_label(): + assert get_forthcoming_label(single_version_rst) is None + assert get_forthcoming_label(single_forthcoming_rst) == 'Forthcoming' + + +def test_rename_section(): + res = rename_section( + single_forthcoming_rst, + 'Forthcoming', + '0.0.1 (2012-01-31)') + assert res == single_version_rst