@@ -63,16 +63,6 @@ def is_npm_package(self) -> bool:
6363 def is_php_composer (self ) -> bool :
6464 return os .path .isfile ("composer.json" )
6565
66- @property
67- def latest_tag (self ) -> str | None :
68- return get_latest_tag_name ()
69-
70- def tags (self ) -> list | None :
71- """Not a property, only use if necessary"""
72- if self .latest_tag is None :
73- return None
74- return get_tag_names ()
75-
7666 @property
7767 def is_pre_commit_installed (self ) -> bool :
7868 return bool (shutil .which ("pre-commit" ))
@@ -181,31 +171,32 @@ def _ask_name(self) -> str:
181171 return name
182172
183173 def _ask_tag (self ) -> str :
184- latest_tag = self . project_info . latest_tag
174+ latest_tag = get_latest_tag_name ()
185175 if not latest_tag :
186176 out .error ("No Existing Tag. Set tag to v0.0.1" )
187177 return "0.0.1"
188178
189- is_correct_tag = questionary .confirm (
179+ if questionary .confirm (
190180 f"Is { latest_tag } the latest tag?" , style = self .cz .style , default = False
181+ ).unsafe_ask ():
182+ return latest_tag
183+
184+ existing_tags = get_tag_names ()
185+ if not existing_tags :
186+ out .error ("No Existing Tag. Set tag to v0.0.1" )
187+ return "0.0.1"
188+
189+ answer : str = questionary .select (
190+ "Please choose the latest tag: " ,
191+ # The latest tag is most likely with the largest number.
192+ # Thus, listing the existing_tags in reverse order makes more sense.
193+ choices = sorted (existing_tags , reverse = True ),
194+ style = self .cz .style ,
191195 ).unsafe_ask ()
192- if not is_correct_tag :
193- tags = self .project_info .tags ()
194- if not tags :
195- out .error ("No Existing Tag. Set tag to v0.0.1" )
196- return "0.0.1"
197-
198- # the latest tag is most likely with the largest number. Thus list the tags in reverse order makes more sense
199- sorted_tags = sorted (tags , reverse = True )
200- latest_tag = questionary .select (
201- "Please choose the latest tag: " ,
202- choices = sorted_tags ,
203- style = self .cz .style ,
204- ).unsafe_ask ()
205196
206- if not latest_tag :
207- raise NoAnswersError ("Tag is required!" )
208- return latest_tag
197+ if not answer :
198+ raise NoAnswersError ("Tag is required!" )
199+ return answer
209200
210201 def _ask_tag_format (self , latest_tag : str ) -> str :
211202 is_correct_format = False
0 commit comments