From bc624ee1270e926e6e5d6954026672360969ba77 Mon Sep 17 00:00:00 2001 From: LeeW Date: Tue, 19 Nov 2019 16:42:53 -0500 Subject: [PATCH 01/18] feat(git): add get_latest_tag, get_all_tags #57 --- commitizen/git.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/commitizen/git.py b/commitizen/git.py index db307d4510..a53ffa3179 100644 --- a/commitizen/git.py +++ b/commitizen/git.py @@ -1,5 +1,6 @@ import os from tempfile import NamedTemporaryFile +from typing import Optional, List from commitizen import cmd @@ -40,3 +41,17 @@ def is_staging_clean() -> bool: c = cmd.run("git diff --no-ext-diff --name-only") c_cached = cmd.run("git diff --no-ext-diff --cached --name-only") return not (bool(c.out) or bool(c_cached.out)) + + +def get_latest_tag() -> Optional[str]: + c = cmd.run("git describe --abbrev=0 --tags") + if c.err: + return None + return c.out + + +def get_all_tags() -> Optional[List[str]]: + c = cmd.run("git tag --list") + if c.err: + return [] + return [tag.strip() for tag in c.out.split("\n") if tag.strip()] From 45337982ddd07248410fcdf4eda458d7b9144644 Mon Sep 17 00:00:00 2001 From: LeeW Date: Tue, 19 Nov 2019 16:44:01 -0500 Subject: [PATCH 02/18] feat(commands/init): Implment init command set tag and tag_format --- commitizen/commands/__init__.py | 4 +- commitizen/commands/init.py | 84 +++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 commitizen/commands/init.py diff --git a/commitizen/commands/__init__.py b/commitizen/commands/__init__.py index 051429f52f..99878d07c2 100644 --- a/commitizen/commands/__init__.py +++ b/commitizen/commands/__init__.py @@ -6,5 +6,7 @@ from .list_cz import ListCz from .schema import Schema from .version import Version +from .init import Init -__all__ = ("Bump", "Check", "Commit", "Example", "Info", "ListCz", "Schema", "Version") + +__all__ = ("Bump", "Check", "Commit", "Example", "Info", "ListCz", "Schema", "Version", "Init") diff --git a/commitizen/commands/init.py b/commitizen/commands/init.py new file mode 100644 index 0000000000..4f3fd46813 --- /dev/null +++ b/commitizen/commands/init.py @@ -0,0 +1,84 @@ +import questionary +import tomlkit +from tomlkit.toml_file import TOMLFile + +from commitizen import factory, out +from commitizen.config import _conf +from commitizen.git import get_latest_tag, get_all_tags + + +class Init: + def __init__(self, config: dict, *args): + self.config: dict = config + self.cz = factory.commiter_factory(self.config) + + def __call__(self): + values_to_add = {} + + if "version" not in self.config: + tag = self._ask_tag() + values_to_add["version"] = tag + else: + tag = self.config["version"] + + if not "tag_format" not in self.config: + tag_format = self._ask_tag_format(tag) + values_to_add["tag_format"] = tag_format + + self._update_config_file(values_to_add) + out.write("The configuration are all set.") + + def _ask_tag(self) -> str: + latest_tag = get_latest_tag() + is_correct_tag = questionary.confirm( + f"Is {latest_tag} the latest tag?", style=self.cz.style, default=False + ).ask() + if not is_correct_tag: + tags = get_all_tags() + # TODO: handle the case that no tag exists in the project + if not tags: + out.error("No Existing Tag") + raise SystemExit() + + latest_tag = questionary.select( + "Please choose the latest tag: ", + choices=get_all_tags(), + style=self.cz.style, + ).ask() + + if not latest_tag: + out.error("Tag is required!") + raise SystemExit() + return latest_tag + + def _ask_tag_format(self, latest_tag) -> str: + is_correct_format = False + if latest_tag.startswith("v"): + tag_format = r"v$version" + is_correct_format = questionary.confirm( + f'Is "{tag_format}" the correct tag format?', style=self.cz.style + ).ask() + + if not is_correct_format: + tag_format = questionary.text( + "Please enter the correct version format: ", style=self.cz.style + ).ask() + + if not tag_format: + out.error("Tag format is required!") + raise SystemExit() + return tag_format + + def _update_config_file(self, values): + if not values: + out.write("The configuration were all set. Nothing to add.") + raise SystemExit() + + with open(_conf._path, "r") as f: + toml_config = tomlkit.parse(f.read()) + + for key, value in values.items(): + toml_config["tool"]["commitizen"][key] = value + + config_file = TOMLFile(_conf._path) + config_file.write(toml_config) From f9f80e05f00d27a8c885fe7820d8ce66a768430d Mon Sep 17 00:00:00 2001 From: LeeW Date: Tue, 19 Nov 2019 16:44:28 -0500 Subject: [PATCH 03/18] feat(cli): add init command into cli --- commitizen/cli.py | 1 + 1 file changed, 1 insertion(+) diff --git a/commitizen/cli.py b/commitizen/cli.py index da170eefdd..95416cd9a2 100644 --- a/commitizen/cli.py +++ b/commitizen/cli.py @@ -135,6 +135,7 @@ } ], }, + {"name": ["init"], "help": "init commitizen configuration", "func": commands.Init}, ], }, } From ca5d598b48dbd125f051596f2d743238c7842681 Mon Sep 17 00:00:00 2001 From: LeeW Date: Tue, 19 Nov 2019 16:59:19 -0500 Subject: [PATCH 04/18] fix(commands/init): fix logic error #57 --- commitizen/commands/init.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commitizen/commands/init.py b/commitizen/commands/init.py index 4f3fd46813..8d48cfe136 100644 --- a/commitizen/commands/init.py +++ b/commitizen/commands/init.py @@ -21,7 +21,7 @@ def __call__(self): else: tag = self.config["version"] - if not "tag_format" not in self.config: + if "tag_format" not in self.config: tag_format = self._ask_tag_format(tag) values_to_add["tag_format"] = tag_format From 1f8a8df61123101cc17bd5920978ffa9c856cb3c Mon Sep 17 00:00:00 2001 From: LeeW Date: Tue, 19 Nov 2019 17:00:20 -0500 Subject: [PATCH 05/18] test(commands/init): add test case for init command --- tests/test_commands.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/test_commands.py b/tests/test_commands.py index e26d5be318..8ceb88aebf 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -166,14 +166,12 @@ def test_schema(config): def test_list_cz(config): with mock.patch("commitizen.out.write") as mocked_write: - commands.ListCz(config)() mocked_write.assert_called_once() def test_version(config): with mock.patch("commitizen.out.write") as mocked_write: - commands.Version(config)() mocked_write.assert_called_once() @@ -214,3 +212,16 @@ def test_check_conventional_commit(config, mocker): def test_check_command_when_commit_file_not_found(config): with pytest.raises(FileNotFoundError): commands.Check(config=config, arguments={"commit_msg_file": ""})() + + +def test_init(capsys): + config = { + "name": defaults.name, + "version": "0.1.0", + "tag_format": r"$version", + } + with pytest.raises(SystemExit): + commands.Init(config)() + + captured = capsys.readouterr() + assert "The configuration were all set. Nothing to add." == captured.out From 9f887483b42774ce797c8abc8a5c571103c0fbdb Mon Sep 17 00:00:00 2001 From: LeeW Date: Tue, 19 Nov 2019 17:00:57 -0500 Subject: [PATCH 06/18] style(all): black --- commitizen/cli.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/commitizen/cli.py b/commitizen/cli.py index 95416cd9a2..e3af3a8073 100644 --- a/commitizen/cli.py +++ b/commitizen/cli.py @@ -135,7 +135,11 @@ } ], }, - {"name": ["init"], "help": "init commitizen configuration", "func": commands.Init}, + { + "name": ["init"], + "help": "init commitizen configuration", + "func": commands.Init, + }, ], }, } From 37e82be4be49debc94ddec3430aae95116410f46 Mon Sep 17 00:00:00 2001 From: LeeW Date: Fri, 22 Nov 2019 23:13:59 -0500 Subject: [PATCH 07/18] feat(commands/init): add name into init question --- commitizen/commands/init.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/commitizen/commands/init.py b/commitizen/commands/init.py index 8d48cfe136..26d8889688 100644 --- a/commitizen/commands/init.py +++ b/commitizen/commands/init.py @@ -3,18 +3,24 @@ from tomlkit.toml_file import TOMLFile from commitizen import factory, out +from commitizen.cz import registry from commitizen.config import _conf from commitizen.git import get_latest_tag, get_all_tags class Init: def __init__(self, config: dict, *args): + # TODO: distinguish default and file config self.config: dict = config self.cz = factory.commiter_factory(self.config) def __call__(self): values_to_add = {} + if "name" not in self.config: + name = self._ask_name() + values_to_add["name"] = name + if "version" not in self.config: tag = self._ask_tag() values_to_add["version"] = tag @@ -28,6 +34,15 @@ def __call__(self): self._update_config_file(values_to_add) out.write("The configuration are all set.") + def _ask_name(self) -> str: + name = questionary.select( + "Please choose the latest tag: ", + choices=list(registry.keys()), + default="cz_conventional_commits", + style=self.cz.style, + ).ask() + return name + def _ask_tag(self) -> str: latest_tag = get_latest_tag() is_correct_tag = questionary.confirm( From 8ea9618de698721345c7220f2f31620b853fef60 Mon Sep 17 00:00:00 2001 From: LeeW Date: Tue, 19 Nov 2019 16:44:01 -0500 Subject: [PATCH 08/18] feat(commands/init): Implment init command set tag and tag_format --- commitizen/commands/init.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commitizen/commands/init.py b/commitizen/commands/init.py index 26d8889688..df916413d3 100644 --- a/commitizen/commands/init.py +++ b/commitizen/commands/init.py @@ -27,7 +27,7 @@ def __call__(self): else: tag = self.config["version"] - if "tag_format" not in self.config: + if not "tag_format" not in self.config: tag_format = self._ask_tag_format(tag) values_to_add["tag_format"] = tag_format From b7c8df2cd5f7bc00563e1a1244a39c7c093e8254 Mon Sep 17 00:00:00 2001 From: LeeW Date: Tue, 19 Nov 2019 16:59:19 -0500 Subject: [PATCH 09/18] fix(commands/init): fix logic error #57 --- commitizen/commands/init.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commitizen/commands/init.py b/commitizen/commands/init.py index df916413d3..26d8889688 100644 --- a/commitizen/commands/init.py +++ b/commitizen/commands/init.py @@ -27,7 +27,7 @@ def __call__(self): else: tag = self.config["version"] - if not "tag_format" not in self.config: + if "tag_format" not in self.config: tag_format = self._ask_tag_format(tag) values_to_add["tag_format"] = tag_format From ad2bb0292c3085c9fd5fe94076a579cf9dc41406 Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Thu, 26 Dec 2019 11:01:31 +0800 Subject: [PATCH 10/18] fix(commands/init): fix init command broken due to newly refactored config --- commitizen/commands/init.py | 40 ++++++++++++------------------------- tests/test_commands.py | 14 ++++++------- 2 files changed, 19 insertions(+), 35 deletions(-) diff --git a/commitizen/commands/init.py b/commitizen/commands/init.py index 26d8889688..70f6194ba3 100644 --- a/commitizen/commands/init.py +++ b/commitizen/commands/init.py @@ -1,42 +1,35 @@ import questionary -import tomlkit -from tomlkit.toml_file import TOMLFile from commitizen import factory, out from commitizen.cz import registry -from commitizen.config import _conf +from commitizen.config import BaseConfig from commitizen.git import get_latest_tag, get_all_tags class Init: - def __init__(self, config: dict, *args): - # TODO: distinguish default and file config - self.config: dict = config + def __init__(self, config: BaseConfig, *args): + self.config: BaseConfig = config self.cz = factory.commiter_factory(self.config) def __call__(self): values_to_add = {} - if "name" not in self.config: - name = self._ask_name() - values_to_add["name"] = name - - if "version" not in self.config: + # No config file exist + if not self.config.path: + values_to_add["name"] = self._ask_name() tag = self._ask_tag() values_to_add["version"] = tag + values_to_add["tag_format"] = self._ask_tag_format(tag) else: - tag = self.config["version"] - - if "tag_format" not in self.config: - tag_format = self._ask_tag_format(tag) - values_to_add["tag_format"] = tag_format + out.line(f"Config file {self.config.path} already exists") + raise SystemExit() self._update_config_file(values_to_add) out.write("The configuration are all set.") def _ask_name(self) -> str: name = questionary.select( - "Please choose the latest tag: ", + "Please choose a cz: ", choices=list(registry.keys()), default="cz_conventional_commits", style=self.cz.style, @@ -50,10 +43,9 @@ def _ask_tag(self) -> str: ).ask() if not is_correct_tag: tags = get_all_tags() - # TODO: handle the case that no tag exists in the project if not tags: - out.error("No Existing Tag") - raise SystemExit() + out.line("No Existing Tag. Set tag to v0.0.1") + return "v0.0.1" latest_tag = questionary.select( "Please choose the latest tag: ", @@ -89,11 +81,5 @@ def _update_config_file(self, values): out.write("The configuration were all set. Nothing to add.") raise SystemExit() - with open(_conf._path, "r") as f: - toml_config = tomlkit.parse(f.read()) - for key, value in values.items(): - toml_config["tool"]["commitizen"][key] = value - - config_file = TOMLFile(_conf._path) - config_file.write(toml_config) + self.config.set_key(key, value) diff --git a/tests/test_commands.py b/tests/test_commands.py index 8ceb88aebf..de0a7847df 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -214,14 +214,12 @@ def test_check_command_when_commit_file_not_found(config): commands.Check(config=config, arguments={"commit_msg_file": ""})() -def test_init(capsys): - config = { - "name": defaults.name, - "version": "0.1.0", - "tag_format": r"$version", - } +def test_init_when_config_already_exists(config, capsys): + # Set config path + path = "tests/pyproject.toml" + config.add_path(path) + with pytest.raises(SystemExit): commands.Init(config)() - captured = capsys.readouterr() - assert "The configuration were all set. Nothing to add." == captured.out + assert captured.out == f"Config file {path} already exists\n" From e65087cf07343414772fc373177a9e62f85bc14b Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Thu, 26 Dec 2019 11:19:04 +0800 Subject: [PATCH 11/18] style(commands): blackify --- commitizen/commands/__init__.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/commitizen/commands/__init__.py b/commitizen/commands/__init__.py index 99878d07c2..e315a987c9 100644 --- a/commitizen/commands/__init__.py +++ b/commitizen/commands/__init__.py @@ -9,4 +9,14 @@ from .init import Init -__all__ = ("Bump", "Check", "Commit", "Example", "Info", "ListCz", "Schema", "Version", "Init") +__all__ = ( + "Bump", + "Check", + "Commit", + "Example", + "Info", + "ListCz", + "Schema", + "Version", + "Init", +) From 001d8483e32b7df62e5ef9d79128d167e6b97017 Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Thu, 26 Dec 2019 12:17:04 +0800 Subject: [PATCH 12/18] feat(config): add init_empty_config_file --- commitizen/config/ini_config.py | 4 ++++ commitizen/config/toml_config.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/commitizen/config/ini_config.py b/commitizen/config/ini_config.py index 5c02e22e9b..8fcb525719 100644 --- a/commitizen/config/ini_config.py +++ b/commitizen/config/ini_config.py @@ -22,6 +22,10 @@ def __init__(self, *, data: str, path: str): self._parse_setting(data) self.add_path(path) + def init_empty_config_file(self): + with open(self.path, "w") as toml_file: + toml_file.write("[commitizen]") + def set_key(self, key, value): """Set or update a key in the conf. diff --git a/commitizen/config/toml_config.py b/commitizen/config/toml_config.py index 7e669b18e0..bbd7fd440c 100644 --- a/commitizen/config/toml_config.py +++ b/commitizen/config/toml_config.py @@ -10,6 +10,10 @@ def __init__(self, *, data: str, path: str): self._parse_setting(data) self.add_path(path) + def init_empty_config_file(self): + with open(self.path, "w") as toml_file: + toml_file.write("[tool.commitizen]") + def set_key(self, key, value): """Set or update a key in the conf. From 2bacb27e0f9fd0153e4535f9e86675be6fb1cf6e Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Thu, 26 Dec 2019 12:17:38 +0800 Subject: [PATCH 13/18] fix(commands/init): fix init commands cannot create config file --- commitizen/commands/init.py | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/commitizen/commands/init.py b/commitizen/commands/init.py index 70f6194ba3..5dc8c822a8 100644 --- a/commitizen/commands/init.py +++ b/commitizen/commands/init.py @@ -2,8 +2,9 @@ from commitizen import factory, out from commitizen.cz import registry -from commitizen.config import BaseConfig +from commitizen.config import BaseConfig, TomlConfig, IniConfig from commitizen.git import get_latest_tag, get_all_tags +from commitizen.defaults import config_files class Init: @@ -16,20 +17,37 @@ def __call__(self): # No config file exist if not self.config.path: + config_path = self._ask_config_path() + + if "toml" in config_path: + self.config = TomlConfig(data="", path=config_path) + else: + self.config = IniConfig(data="", path=config_path) + + self.config.init_empty_config_file() + values_to_add["name"] = self._ask_name() tag = self._ask_tag() values_to_add["version"] = tag values_to_add["tag_format"] = self._ask_tag_format(tag) + self._update_config_file(values_to_add) + out.write("The configuration are all set.") else: + # TODO: handle the case that config file exist but no value out.line(f"Config file {self.config.path} already exists") - raise SystemExit() - self._update_config_file(values_to_add) - out.write("The configuration are all set.") + def _ask_config_path(self) -> str: + name = questionary.select( + "Please choose a supported config file: (default: pyproject.tml)", + choices=config_files, + default="pyproject.toml", + style=self.cz.style, + ).ask() + return name def _ask_name(self) -> str: name = questionary.select( - "Please choose a cz: ", + "Please choose a cz: (default: cz_conventional_commits)", choices=list(registry.keys()), default="cz_conventional_commits", style=self.cz.style, @@ -38,14 +56,18 @@ def _ask_name(self) -> str: def _ask_tag(self) -> str: latest_tag = get_latest_tag() + if not latest_tag: + out.error("No Existing Tag. Set tag to v0.0.1") + return 'v0.0.1' + is_correct_tag = questionary.confirm( f"Is {latest_tag} the latest tag?", style=self.cz.style, default=False ).ask() if not is_correct_tag: tags = get_all_tags() if not tags: - out.line("No Existing Tag. Set tag to v0.0.1") - return "v0.0.1" + out.error("No Existing Tag. Set tag to v0.0.1") + return 'v0.0.1' latest_tag = questionary.select( "Please choose the latest tag: ", From 332c2f43ed24de270d9dcbc86eb86f914d93736f Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Thu, 26 Dec 2019 16:52:47 +0800 Subject: [PATCH 14/18] style(commands/init): blackify --- commitizen/commands/init.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commitizen/commands/init.py b/commitizen/commands/init.py index 5dc8c822a8..21f0a9de81 100644 --- a/commitizen/commands/init.py +++ b/commitizen/commands/init.py @@ -58,7 +58,7 @@ def _ask_tag(self) -> str: latest_tag = get_latest_tag() if not latest_tag: out.error("No Existing Tag. Set tag to v0.0.1") - return 'v0.0.1' + return "v0.0.1" is_correct_tag = questionary.confirm( f"Is {latest_tag} the latest tag?", style=self.cz.style, default=False @@ -67,7 +67,7 @@ def _ask_tag(self) -> str: tags = get_all_tags() if not tags: out.error("No Existing Tag. Set tag to v0.0.1") - return 'v0.0.1' + return "v0.0.1" latest_tag = questionary.select( "Please choose the latest tag: ", From 4faf5234d3cee4911e9e745962ed5ffb869e9c17 Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Thu, 26 Dec 2019 16:53:42 +0800 Subject: [PATCH 15/18] fix(commands/init): fix test_init_when_config_already_exists --- tests/test_commands.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/test_commands.py b/tests/test_commands.py index de0a7847df..983b8a0073 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -219,7 +219,6 @@ def test_init_when_config_already_exists(config, capsys): path = "tests/pyproject.toml" config.add_path(path) - with pytest.raises(SystemExit): - commands.Init(config)() - captured = capsys.readouterr() - assert captured.out == f"Config file {path} already exists\n" + commands.Init(config)() + captured = capsys.readouterr() + assert captured.out == f"Config file {path} already exists\n" From 32fe3e79133cb9f8dd789a7143008da1beff1a05 Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Sun, 29 Dec 2019 18:15:55 +0800 Subject: [PATCH 16/18] fix(commands/init): read version in the format "x.y.z" instead of "vx.y.z" --- commitizen/commands/init.py | 8 +++++--- commitizen/git.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/commitizen/commands/init.py b/commitizen/commands/init.py index 21f0a9de81..1e1d5b5642 100644 --- a/commitizen/commands/init.py +++ b/commitizen/commands/init.py @@ -1,3 +1,5 @@ +from packaging.version import Version + import questionary from commitizen import factory, out @@ -28,7 +30,7 @@ def __call__(self): values_to_add["name"] = self._ask_name() tag = self._ask_tag() - values_to_add["version"] = tag + values_to_add["version"] = Version(tag).public values_to_add["tag_format"] = self._ask_tag_format(tag) self._update_config_file(values_to_add) out.write("The configuration are all set.") @@ -58,7 +60,7 @@ def _ask_tag(self) -> str: latest_tag = get_latest_tag() if not latest_tag: out.error("No Existing Tag. Set tag to v0.0.1") - return "v0.0.1" + return "0.0.1" is_correct_tag = questionary.confirm( f"Is {latest_tag} the latest tag?", style=self.cz.style, default=False @@ -67,7 +69,7 @@ def _ask_tag(self) -> str: tags = get_all_tags() if not tags: out.error("No Existing Tag. Set tag to v0.0.1") - return "v0.0.1" + return "0.0.1" latest_tag = questionary.select( "Please choose the latest tag: ", diff --git a/commitizen/git.py b/commitizen/git.py index a53ffa3179..bbd4d7b84b 100644 --- a/commitizen/git.py +++ b/commitizen/git.py @@ -47,7 +47,7 @@ def get_latest_tag() -> Optional[str]: c = cmd.run("git describe --abbrev=0 --tags") if c.err: return None - return c.out + return c.out.strip() def get_all_tags() -> Optional[List[str]]: From 94e512091df84070fa507904952f994cea50f105 Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Mon, 30 Dec 2019 08:37:13 +0800 Subject: [PATCH 17/18] refactor(commands/init): add default for tag_format --- commitizen/commands/init.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/commitizen/commands/init.py b/commitizen/commands/init.py index 1e1d5b5642..7fc39cdd01 100644 --- a/commitizen/commands/init.py +++ b/commitizen/commands/init.py @@ -92,12 +92,12 @@ def _ask_tag_format(self, latest_tag) -> str: if not is_correct_format: tag_format = questionary.text( - "Please enter the correct version format: ", style=self.cz.style + 'Please enter the correct version format: (default: "$version")', + style=self.cz.style, ).ask() if not tag_format: - out.error("Tag format is required!") - raise SystemExit() + tag_format = "$version" return tag_format def _update_config_file(self, values): From 64b56d8a29b785520d60cc36156a0dc5dc6bab96 Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Mon, 30 Dec 2019 09:08:32 +0800 Subject: [PATCH 18/18] docs(index): add init command --- docs/index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/index.md b/docs/index.md index d1c5bbff92..ff10951fb0 100644 --- a/docs/index.md +++ b/docs/index.md @@ -95,6 +95,7 @@ commands: schema show commit schema bump bump semantic version based on the git log check validates that a commit message matches the commitizen schema + init init commitizen configuration ``` ## Contributing