Skip to content

Commit

Permalink
Match only actual source and patch tags (#376)
Browse files Browse the repository at this point in the history
Match only actual source and patch tags

Adjust the conditions so that only tags named "Source" or "Patch" optionally followed by a number are matched and for example the "SourceLicense" tag is not.

Reviewed-by: Laura Barcziová
  • Loading branch information
softwarefactory-project-zuul[bot] authored May 10, 2024
2 parents cd9ee9e + 2261666 commit 0e46977
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions specfile/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,12 @@ def _get_tags(self) -> List[Tuple[TagSource, Tags, int]]:
"""
result = []
last_number = -1
numbered_pattern = re.compile(rf"{self.prefix}\d+")
for i, tag in enumerate(self._tags):
if tag.normalized_name == self.prefix:
last_number += 1
ts = self.tag_class(tag, last_number)
elif tag.normalized_name.startswith(self.prefix):
elif numbered_pattern.match(tag.normalized_name):
ts = self.tag_class(tag)
last_number = ts.number
else:
Expand Down Expand Up @@ -675,11 +676,12 @@ def _get_initial_tag_setup(self, number: int = 0) -> Tuple[int, str, str]:
Returns:
Tuple in the form of (index, name, separator).
"""
source_pattern = re.compile(rf"{Sources.prefix}\d*")
try:
index, source = [
(i, Sources.tag_class(t))
for i, t in enumerate(self._tags)
if t.normalized_name.startswith(Sources.prefix)
if source_pattern.match(t.normalized_name)
][-1]
except IndexError:
return super()._get_initial_tag_setup(number)
Expand Down

0 comments on commit 0e46977

Please sign in to comment.