mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
fix for issue 246
This commit is contained in:
parent
2c70476c63
commit
72b61a81f9
3 changed files with 20 additions and 1 deletions
|
|
@ -27,10 +27,14 @@ IDENTIFYING_HASH = '79f09a650522a87b0da915d0d983b2de'
|
|||
|
||||
|
||||
def is_our_pre_commit(filename):
|
||||
if not os.path.exists(filename):
|
||||
return False
|
||||
return IDENTIFYING_HASH in io.open(filename).read()
|
||||
|
||||
|
||||
def is_previous_pre_commit(filename):
|
||||
if not os.path.exists(filename):
|
||||
return False
|
||||
contents = io.open(filename).read()
|
||||
return any(hash in contents for hash in PREVIOUS_IDENTIFYING_HASHES)
|
||||
|
||||
|
|
@ -53,7 +57,7 @@ def install(runner, overwrite=False, hooks=False, hook_type='pre-commit'):
|
|||
|
||||
# If we have an existing hook, move it to pre-commit.legacy
|
||||
if (
|
||||
os.path.exists(hook_path) and
|
||||
os.path.lexists(hook_path) and
|
||||
not is_our_pre_commit(hook_path) and
|
||||
not is_previous_pre_commit(hook_path)
|
||||
):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue