From 37611747983968ae62e760056c5f771ae4f76fe8 Mon Sep 17 00:00:00 2001 From: John Davis Date: Tue, 2 Jul 2024 15:44:59 -0400 Subject: [PATCH] Fix strip_release bug If there were more than one sets of brackets, the value was replaced by an empty string --- galaxy_release_util/metadata.py | 2 +- tests/test_metadata.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/test_metadata.py diff --git a/galaxy_release_util/metadata.py b/galaxy_release_util/metadata.py index 231feda..df24357 100644 --- a/galaxy_release_util/metadata.py +++ b/galaxy_release_util/metadata.py @@ -98,4 +98,4 @@ def _pr_to_labels(pr: PullRequest) -> List[str]: def strip_release(message): - return re.sub(r"^\s*\[.*\]\s*", r"", message) + return re.sub(r"^\s*\[[\w,\.,-]*\]\s*", r"", message) diff --git a/tests/test_metadata.py b/tests/test_metadata.py new file mode 100644 index 0000000..2cffa54 --- /dev/null +++ b/tests/test_metadata.py @@ -0,0 +1,15 @@ +from galaxy_release_util.metadata import strip_release + + +def test_strip_release(): + """Verify that the first occurance of [*] is stripped out.""" + assert strip_release("foo") == "foo" + assert strip_release("[1]foo") == "foo" + assert strip_release("[1.2.3]foo") == "foo" + assert strip_release("[]foo") == "foo" + assert strip_release("[][]foo") == "[]foo" + assert strip_release("foo[]") == "foo[]" + assert strip_release("[]foo[]") == "foo[]" + assert strip_release("foo[bar]") == "foo[bar]" + assert strip_release("foo[]baz") == "foo[]baz" + assert strip_release("foo[bar]baz") == "foo[bar]baz"