mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Introduce .pre-commit-hooks.yaml as a replacement for hooks.yaml
This commit is contained in:
parent
b90a598fac
commit
b9e5184ebd
32 changed files with 107 additions and 21 deletions
|
|
@ -39,13 +39,17 @@ def make_repo(tempdir_factory, repo_source):
|
|||
|
||||
@contextlib.contextmanager
|
||||
def modify_manifest(path):
|
||||
"""Modify the manifest yielded by this context to write to hooks.yaml."""
|
||||
"""Modify the manifest yielded by this context to write to
|
||||
.pre-commit-hooks.yaml.
|
||||
"""
|
||||
manifest_path = os.path.join(path, C.MANIFEST_FILE)
|
||||
manifest = ordered_load(io.open(manifest_path).read())
|
||||
yield manifest
|
||||
with io.open(manifest_path, 'w') as manifest_file:
|
||||
manifest_file.write(ordered_dump(manifest, **C.YAML_DUMP_KWARGS))
|
||||
cmd_output('git', 'commit', '-am', 'update hooks.yaml', cwd=path)
|
||||
cmd_output(
|
||||
'git', 'commit', '-am', 'update .pre-commit-hooks.yaml', cwd=path,
|
||||
)
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
|
|
@ -75,8 +79,11 @@ def config_with_local_hooks():
|
|||
))
|
||||
|
||||
|
||||
def make_config_from_repo(repo_path, sha=None, hooks=None, check=True):
|
||||
manifest = load_manifest(os.path.join(repo_path, C.MANIFEST_FILE))
|
||||
def make_config_from_repo(
|
||||
repo_path, sha=None, hooks=None, check=True, legacy=False,
|
||||
):
|
||||
filename = C.MANIFEST_FILE_LEGACY if legacy else C.MANIFEST_FILE
|
||||
manifest = load_manifest(os.path.join(repo_path, filename))
|
||||
config = OrderedDict((
|
||||
('repo', repo_path),
|
||||
('sha', sha or get_head_sha(repo_path)),
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
FROM cogniteev/echo
|
||||
|
||||
CMD ["echo", "This is overwritten by the hooks.yaml 'entry'"]
|
||||
CMD ["echo", "This is overwritten by the .pre-commit-hooks.yaml 'entry'"]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
- id: system-hook-with-spaces
|
||||
name: System hook with spaces
|
||||
entry: bash -c 'echo "Hello World"'
|
||||
language: system
|
||||
files: \.sh$
|
||||
Loading…
Add table
Add a link
Reference in a new issue