mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 16:24:40 +04:00
Add tests for alternate config
This commit is contained in:
parent
f205e6d170
commit
727247e6ed
3 changed files with 70 additions and 10 deletions
|
|
@ -94,18 +94,24 @@ def make_config_from_repo(repo_path, sha=None, hooks=None, check=True):
|
|||
return config
|
||||
|
||||
|
||||
def write_config(directory, config):
|
||||
def read_config(directory, config_file=C.CONFIG_FILE):
|
||||
config_path = os.path.join(directory, config_file)
|
||||
config = ordered_load(io.open(config_path).read())
|
||||
return config
|
||||
|
||||
|
||||
def write_config(directory, config, config_file=C.CONFIG_FILE):
|
||||
if type(config) is not list:
|
||||
assert type(config) is OrderedDict
|
||||
config = [config]
|
||||
with io.open(os.path.join(directory, C.CONFIG_FILE), 'w') as config_file:
|
||||
config_file.write(ordered_dump(config, **C.YAML_DUMP_KWARGS))
|
||||
with io.open(os.path.join(directory, config_file), 'w') as outfile:
|
||||
outfile.write(ordered_dump(config, **C.YAML_DUMP_KWARGS))
|
||||
|
||||
|
||||
def add_config_to_repo(git_path, config):
|
||||
write_config(git_path, config)
|
||||
def add_config_to_repo(git_path, config, config_file=C.CONFIG_FILE):
|
||||
write_config(git_path, config, config_file=config_file)
|
||||
with cwd(git_path):
|
||||
cmd_output('git', 'add', C.CONFIG_FILE)
|
||||
cmd_output('git', 'add', config_file)
|
||||
cmd_output('git', 'commit', '-m', 'Add hooks config')
|
||||
return git_path
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue