Skip to content

Commit

Permalink
fix(command-init): "cz init" should list exisitng tag in reverse order
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellie-Yen authored and Lee-W committed Mar 30, 2024
1 parent ffb6df7 commit 7c0e780
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion commitizen/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,11 @@ def _ask_tag(self) -> str:
out.error("No Existing Tag. Set tag to v0.0.1")
return "0.0.1"

# the latest tag is most likely with the largest number. Thus list the tags in reverse order makes more sense
sorted_tags = sorted(tags, reverse=True)
latest_tag = questionary.select(
"Please choose the latest tag: ",
choices=tags,
choices=sorted_tags,
style=self.cz.style,
).unsafe_ask()

Expand Down
2 changes: 1 addition & 1 deletion tests/commands/test_init_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_init_when_config_already_exists(config, capsys):

def test_init_without_choosing_tag(config, mocker: MockFixture, tmpdir):
mocker.patch(
"commitizen.commands.init.get_tag_names", return_value=["0.0.1", "0.0.2"]
"commitizen.commands.init.get_tag_names", return_value=["0.0.2", "0.0.1"]
)
mocker.patch("commitizen.commands.init.get_latest_tag_name", return_value="0.0.2")
mocker.patch(
Expand Down

0 comments on commit 7c0e780

Please sign in to comment.