@@ -113,16 +113,20 @@ def _format_regex(self, tag_pattern: str, star: bool = False) -> str:
113113 format_regex = format_regex .replace (pattern , regex )
114114 return format_regex
115115
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+
116120 def is_version_tag (self , tag : str | GitTag , warn : bool = False ) -> bool :
117121 """
118122 True if a given tag is a legit version tag.
119123
120124 if `warn` is `True`, it will print a warning message if the tag is not a version tag.
121125 """
122126 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 )
124128 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 ) )
126130 return is_legit
127131
128132 def is_ignored_tag (self , tag : str | GitTag ) -> bool :
@@ -146,9 +150,7 @@ def extract_version(self, tag: GitTag) -> Version:
146150 m for regex in self .version_regexes if (m := regex .fullmatch (tag .name ))
147151 )
148152 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 ))
152154 if "version" in m .groupdict ():
153155 return self .scheme (m .group ("version" ))
154156
0 commit comments