def test_commitizen_excepthook(capsys): with pytest.raises(SystemExit) as excinfo: cli.commitizen_excepthook(NotAGitProjectError, NotAGitProjectError(), "") assert excinfo.type == SystemExit assert excinfo.value.code == NotAGitProjectError.exit_code
def read_cfg() -> BaseConfig: conf = BaseConfig() git_project_root = git.find_git_project_root() if not git_project_root: raise NotAGitProjectError() cfg_paths = (path / Path(filename) for path in [Path("."), git_project_root] for filename in defaults.config_files) for filename in cfg_paths: if not filename.exists(): continue with open(filename, "r") as f: data: str = f.read() _conf: Union[TomlConfig, IniConfig] if "toml" in filename.suffix: _conf = TomlConfig(data=data, path=filename) else: _conf = IniConfig(data=data, path=filename) if _conf.is_empty_config: continue else: conf = _conf break if not conf.path: global_conf = load_global_conf() if global_conf: conf = global_conf return conf
def __init__(self, config: BaseConfig, args): if not git.is_git_project(): raise NotAGitProjectError() self.config: BaseConfig = config self.cz = factory.commiter_factory(self.config) self.start_rev = args.get("start_rev") or self.config.settings.get( "changelog_start_rev" ) self.file_name = args.get("file_name") or self.config.settings.get( "changelog_file" ) self.incremental = args["incremental"] or self.config.settings.get( "changelog_incremental" ) self.dry_run = args["dry_run"] self.unreleased_version = args["unreleased_version"] self.change_type_map = ( self.config.settings.get("change_type_map") or self.cz.change_type_map ) self.change_type_order = ( self.config.settings.get("change_type_order") or self.cz.change_type_order ) self.rev_range = args.get("rev_range") self.tag_format = args.get("tag_format") or self.config.settings.get( "tag_format" )
def __init__(self, config: BaseConfig, arguments: dict): if not git.is_git_project(): raise NotAGitProjectError() self.config: BaseConfig = config self.arguments: dict = arguments self.bump_settings: dict = { **config.settings, **{ key: arguments[key] for key in [ "tag_format", "prerelease", "increment", "bump_message", "annotated_tag", ] if arguments[key] is not None }, } self.cz = factory.commiter_factory(self.config) self.changelog = arguments["changelog"] or self.config.settings.get( "update_changelog_on_bump") self.changelog_to_stdout = arguments["changelog_to_stdout"] self.no_verify = arguments["no_verify"] self.check_consistency = arguments["check_consistency"] self.retry = arguments["retry"]
def __init__(self, config: BaseConfig, arguments: dict): if not git.is_git_project(): raise NotAGitProjectError() self.config: BaseConfig = config self.cz = factory.commiter_factory(self.config) self.arguments = arguments self.temp_file: str = os.path.join(tempfile.gettempdir(), "cz.commit.backup")
def test_commitizen_debug_excepthook(capsys): with pytest.raises(SystemExit) as excinfo: cli.commitizen_excepthook( NotAGitProjectError, NotAGitProjectError(), "", debug=True, ) assert excinfo.type == SystemExit assert excinfo.value.code == NotAGitProjectError.exit_code assert "NotAGitProjectError" in str(excinfo.traceback[0])
def __init__(self, commiter_name="cz_conventional_commits"): """""" if not git.is_git_project(): raise NotAGitProjectError() self.cz = get_commiter(commiter_name) self.commiter_name = commiter_name