Add utility for parsing shebangs and resolving PATH

This commit is contained in:
Anthony Sottile 2016-03-21 21:08:44 -07:00
parent a932315a15
commit 82369fd99f
6 changed files with 267 additions and 13 deletions

View file

@ -5,10 +5,10 @@ import io
import logging
import os
import os.path
import stat
import sys
from pre_commit.logging_handler import LoggingHandler
from pre_commit.util import make_executable
from pre_commit.util import mkdirp
from pre_commit.util import resource_filename
@ -42,14 +42,6 @@ def is_previous_pre_commit(filename):
return any(hash in contents for hash in PREVIOUS_IDENTIFYING_HASHES)
def make_executable(filename):
original_mode = os.stat(filename).st_mode
os.chmod(
filename,
original_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH,
)
def install(runner, overwrite=False, hooks=False, hook_type='pre-commit'):
"""Install the pre-commit hooks."""
hook_path = runner.get_hook_path(hook_type)