Checks if the given branch_name matches any of the patterns in self.branches.
If a match is found, returns the label name; otherwise, returns None.
Assumes self.branches can contain regular expression patterns.
Source code in src/setuptools_scmx/models.py
22
23
24
25
26
27
28
29
30
31
32
33 | def match(self, branch_name: str | None) -> LabelName | None:
"""
Checks if the given branch_name matches any of the patterns in self.branches.
If a match is found, returns the label name; otherwise, returns None.
Assumes `self.branches` can contain regular expression patterns.
"""
if branch_name is None:
return None
# Iterate through branch patterns and return the label name on the first match.
if any(re.match(pattern, branch_name) for pattern in self.branches):
return self.name
return None
|