Harmonize containing branch matcher for tags

Perform a `re.match()` instead of `re.fullmatch()` for the containing
branches for tag triggered items. Requiring a full match is unexpected
for users.

Change-Id: Icd8c258b0dfc36df8c94d9cb5edb3125804b9bc4
This commit is contained in:
Simon Westphahl
2024-08-07 12:56:03 +02:00
parent 3efb931373
commit 6ffcafb77e
3 changed files with 14 additions and 1 deletions

View File

@@ -71,6 +71,13 @@ class TestBranchMatcher(BaseTestMatcher):
self.change.ref = 'baz'
self.assertFalse(self.matcher.matches(self.change))
def test_containing_branch_partial_match(self):
self.change = model.Tag(self.project)
self.change.ref = 'refs/tags/1.0'
self.matcher = cm.BranchMatcher(ZuulRegex('^release-'))
self.change.containing_branches = ["release-1.0", "master"]
self.assertTrue(self.matcher.matches(self.change))
class TestAbstractMatcherCollection(BaseTestMatcher):

View File

@@ -0,0 +1,6 @@
---
upgrade:
- |
The branch matcher for containing branches of a tag will now perform a
normal regex match instead of requiring a full-match. This was done to
harmonize the matching behavior between the different change-types.

View File

@@ -88,7 +88,7 @@ class BranchMatcher(AbstractChangeMatcher):
if self._regex == branch:
return True
else:
if self.regex.fullmatch(branch):
if self.regex.match(branch):
return True
return False