mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 16:24:40 +04:00
Move commands into their own files.
This commit is contained in:
parent
111ed02938
commit
cdfd3f7670
16 changed files with 736 additions and 673 deletions
24
pre_commit/commands/install.py
Normal file
24
pre_commit/commands/install.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
import pkg_resources
|
||||
import stat
|
||||
|
||||
|
||||
def install(runner):
|
||||
"""Install the pre-commit hooks."""
|
||||
pre_commit_file = pkg_resources.resource_filename(
|
||||
'pre_commit', 'resources/pre-commit.sh',
|
||||
)
|
||||
with open(runner.pre_commit_path, 'w') as pre_commit_file_obj:
|
||||
pre_commit_file_obj.write(open(pre_commit_file).read())
|
||||
|
||||
original_mode = os.stat(runner.pre_commit_path).st_mode
|
||||
os.chmod(
|
||||
runner.pre_commit_path,
|
||||
original_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH,
|
||||
)
|
||||
|
||||
print('pre-commit installed at {0}'.format(runner.pre_commit_path))
|
||||
return 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue