@@ -113,16 +113,20 @@ def _format_regex(self, tag_pattern: str, star: bool = False) -> str:
113
113
format_regex = format_regex .replace (pattern , regex )
114
114
return format_regex
115
115
116
+ def _version_tag_error (self , tag : str ) -> str :
117
+ """Format the error message for an invalid version tag"""
118
+ return f"Invalid version tag: '{ tag } ' does not match any configured tag format"
119
+
116
120
def is_version_tag (self , tag : str | GitTag , warn : bool = False ) -> bool :
117
121
"""
118
122
True if a given tag is a legit version tag.
119
123
120
124
if `warn` is `True`, it will print a warning message if the tag is not a version tag.
121
125
"""
122
126
tag = tag .name if isinstance (tag , GitTag ) else tag
123
- is_legit = any (regex .match (tag ) for regex in self .version_regexes )
127
+ is_legit = any (regex .fullmatch (tag ) for regex in self .version_regexes )
124
128
if warn and not is_legit and not self .is_ignored_tag (tag ):
125
- out .warn (f"InvalidVersion { tag } doesn't match any configured tag format" )
129
+ out .warn (self . _version_tag_error ( tag ) )
126
130
return is_legit
127
131
128
132
def is_ignored_tag (self , tag : str | GitTag ) -> bool :
@@ -146,9 +150,7 @@ def extract_version(self, tag: GitTag) -> Version:
146
150
m for regex in self .version_regexes if (m := regex .fullmatch (tag .name ))
147
151
)
148
152
if not (m := next (candidates , None )):
149
- raise InvalidVersion (
150
- f"Invalid version tag: '{ tag .name } ' does not match any configured tag format"
151
- )
153
+ raise InvalidVersion (self ._version_tag_error (tag .name ))
152
154
if "version" in m .groupdict ():
153
155
return self .scheme (m .group ("version" ))
154
156
0 commit comments