@@ -63,16 +63,6 @@ def is_npm_package(self) -> bool:
63
63
def is_php_composer (self ) -> bool :
64
64
return os .path .isfile ("composer.json" )
65
65
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
-
76
66
@property
77
67
def is_pre_commit_installed (self ) -> bool :
78
68
return bool (shutil .which ("pre-commit" ))
@@ -181,31 +171,32 @@ def _ask_name(self) -> str:
181
171
return name
182
172
183
173
def _ask_tag (self ) -> str :
184
- latest_tag = self . project_info . latest_tag
174
+ latest_tag = get_latest_tag_name ()
185
175
if not latest_tag :
186
176
out .error ("No Existing Tag. Set tag to v0.0.1" )
187
177
return "0.0.1"
188
178
189
- is_correct_tag = questionary .confirm (
179
+ if questionary .confirm (
190
180
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
+ ans : 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 ,
191
195
).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 ()
205
196
206
- if not latest_tag :
207
- raise NoAnswersError ("Tag is required!" )
208
- return latest_tag
197
+ if not ans :
198
+ raise NoAnswersError ("Tag is required!" )
199
+ return ans
209
200
210
201
def _ask_tag_format (self , latest_tag : str ) -> str :
211
202
is_correct_format = False
0 commit comments