mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Make the pre-commit actually executable. Closes #32
This commit is contained in:
parent
601e643960
commit
6188903ed7
2 changed files with 8 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ import os
|
||||||
import os.path
|
import os.path
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
import re
|
import re
|
||||||
|
import stat
|
||||||
from plumbum import local
|
from plumbum import local
|
||||||
|
|
||||||
from pre_commit.util import memoize_by_cwd
|
from pre_commit.util import memoize_by_cwd
|
||||||
|
|
@ -32,6 +33,8 @@ def create_pre_commit():
|
||||||
path = get_pre_commit_path()
|
path = get_pre_commit_path()
|
||||||
pre_commit_file = pkg_resources.resource_filename('pre_commit', 'resources/pre-commit.sh')
|
pre_commit_file = pkg_resources.resource_filename('pre_commit', 'resources/pre-commit.sh')
|
||||||
local.path(path).write(local.path(pre_commit_file).read())
|
local.path(path).write(local.path(pre_commit_file).read())
|
||||||
|
original_mode = os.stat(path).st_mode
|
||||||
|
os.chmod(path, original_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
|
||||||
|
|
||||||
|
|
||||||
def remove_pre_commit():
|
def remove_pre_commit():
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
|
import stat
|
||||||
from plumbum import local
|
from plumbum import local
|
||||||
|
|
||||||
from pre_commit import git
|
from pre_commit import git
|
||||||
|
|
@ -25,6 +26,10 @@ def test_get_pre_commit_path(empty_git_dir):
|
||||||
def test_create_pre_commit(empty_git_dir):
|
def test_create_pre_commit(empty_git_dir):
|
||||||
git.create_pre_commit()
|
git.create_pre_commit()
|
||||||
assert len(open(git.get_pre_commit_path(), 'r').read()) > 0
|
assert len(open(git.get_pre_commit_path(), 'r').read()) > 0
|
||||||
|
stat_result = os.stat(git.get_pre_commit_path())
|
||||||
|
assert stat_result.st_mode & stat.S_IXUSR
|
||||||
|
assert stat_result.st_mode & stat.S_IXGRP
|
||||||
|
assert stat_result.st_mode & stat.S_IXOTH
|
||||||
|
|
||||||
|
|
||||||
def test_remove_pre_commit(empty_git_dir):
|
def test_remove_pre_commit(empty_git_dir):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue