Ejemplo n.º 1
0
    def __call__(self):
        values_to_add = {}

        # No config for commitizen exist
        if not self.config.path:
            config_path = self._ask_config_path()
            if "toml" in config_path:
                self.config = TomlConfig(data="", path=config_path)
            elif "json" in config_path:
                self.config = JsonConfig(data="{}", path=config_path)
            elif "yaml" in config_path:
                self.config = YAMLConfig(data="", path=config_path)

            self.config.init_empty_config_content()

            values_to_add["name"] = self._ask_name()
            tag = self._ask_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)

            if questionary.confirm(
                    "Do you want to install pre-commit hook?").ask():
                self._install_pre_commit_hook()

            out.write(
                "You can bump the version and create changelog running:\n")
            out.info("cz bump --changelog")
            out.success("The configuration are all set.")
        else:
            out.line(f"Config file {self.config.path} already exists")
Ejemplo n.º 2
0
def config_customize():
    json_string = r"""{
      "commitizen": {
        "name": "cz_customize",
        "version": "3.0.0",
        "changelog_incremental": "true",
        "customize": {
          "message_template": "{{prefix}}({{scope}}): {{subject}}\n\n{{body}}{% if is_breaking_change %}\nBREAKING CHANGE: {{footer}}{% endif %}",
          "schema": "<type>(<scope>): <subject>\n<BLANK LINE>\n<body>\n<BLANK LINE>\n(BREAKING CHANGE: <footer>)",
          "schema_pattern": "(build|ci|docs|feat|fix|perf|refactor|style|test|chore|revert|bump)(\\(\\S+\\))?!?:(\\s.*)",
          "change_type_map": {
            "feat": "Feat",
            "fix": "Fix",
            "refactor": "Refactor",
            "perf": "Perf"
          },
          "change_type_order": ["Refactor", "Feat"],
          "commit_parser": "^(?P<change_type>feat|fix|refactor|perf|BREAKING CHANGE)(?:\\((?P<scope>[^()\\r\\n]*)\\)|\\()?(?P<breaking>!)?:\\s(?P<message>.*)?",
          "changelog_pattern": "^(BREAKING[\\-\\ ]CHANGE|feat|fix|refactor|perf)(\\(.+\\))?(!)?",
          "questions": [

          ]
        }
      }
    }"""
    _config = JsonConfig(data=json_string, path="not_exist.json")
    return _config
Ejemplo n.º 3
0
  customize:
    message_template: "{{change_type}}:{% if show_message %} {{message}}{% endif %}"
    example: 'feature: this feature enable customize through config file'
    schema: "<type>: <body>"
    bump_pattern: "^(break|new|fix|hotfix)"
    bump_map:
      break: MAJOR
      new: MINOR
      fix: PATCH
      hotfix: PATCH
"""


@pytest.fixture(params=[
    TomlConfig(data=TOML_STR, path="not_exist.toml"),
    JsonConfig(data=JSON_STR, path="not_exist.json"),
])
def config(request):
    """Parametrize the config fixture

    This fixture allow to test multiple config formats,
    without add the builtin parametrize decorator
    """
    return request.param


@pytest.fixture(params=[
    TomlConfig(data=TOML_STR_INFO_PATH, path="not_exist.toml"),
    JsonConfig(data=JSON_STR_INFO_PATH, path="not_exist.json"),
    YAMLConfig(data=YAML_STR_INFO_PATH, path="not_exist.yaml"),
])