def test_install_disallow_mising_config(tempdir_factory): path = make_consuming_repo(tempdir_factory, 'script_hooks_repo') with cwd(path): runner = Runner(path, C.CONFIG_FILE) remove_config_from_repo(path) assert install(runner, overwrite=True, skip_on_missing_conf=False) == 0 ret, output = _get_commit_output(tempdir_factory) assert ret == 1
def test_install_allow_mising_config(tempdir_factory): path = make_consuming_repo(tempdir_factory, 'script_hooks_repo') with cwd(path): runner = Runner(path, C.CONFIG_FILE) remove_config_from_repo(path) assert install(runner, overwrite=True, skip_on_missing_conf=True) == 0 ret, output = _get_commit_output(tempdir_factory) assert ret == 0 expected = ( '`.pre-commit-config.yaml` config file not found. ' 'Skipping `pre-commit`.' ) assert expected in output
def test_install_temporarily_allow_mising_config(tempdir_factory): path = make_consuming_repo(tempdir_factory, 'script_hooks_repo') with cwd(path): runner = Runner(path, C.CONFIG_FILE) remove_config_from_repo(path) assert install(runner, overwrite=True, skip_on_missing_conf=False) == 0 env = dict(os.environ, PRE_COMMIT_ALLOW_NO_CONFIG='1') ret, output = _get_commit_output(tempdir_factory, env=env) assert ret == 0 expected = ( '`.pre-commit-config.yaml` config file not found. ' 'Skipping `pre-commit`.' ) assert expected in output
def test_install_temporarily_allow_mising_config(tempdir_factory, store): path = make_consuming_repo(tempdir_factory, 'script_hooks_repo') with cwd(path): remove_config_from_repo(path) ret = install( C.CONFIG_FILE, store, overwrite=True, skip_on_missing_conf=False, ) assert ret == 0 env = dict(os.environ, PRE_COMMIT_ALLOW_NO_CONFIG='1') ret, output = _get_commit_output(tempdir_factory, env=env) assert ret == 0 expected = ('`.pre-commit-config.yaml` config file not found. ' 'Skipping `pre-commit`.') assert expected in output
def test_install_allow_missing_config(tempdir_factory, store): path = make_consuming_repo(tempdir_factory, 'script_hooks_repo') with cwd(path): remove_config_from_repo(path) ret = install( C.CONFIG_FILE, store, hook_types=['pre-commit'], overwrite=True, skip_on_missing_config=True, ) assert ret == 0 ret, output = _get_commit_output(tempdir_factory) assert ret == 0 expected = ('`.pre-commit-config.yaml` config file not found. ' 'Skipping `pre-commit`.') assert expected in output