mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Use in_git_dir in more places
This commit is contained in:
parent
2af0b0b4f3
commit
d46bbc486f
7 changed files with 88 additions and 143 deletions
|
|
@ -2,7 +2,6 @@ from __future__ import absolute_import
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import collections
|
||||
import io
|
||||
import os.path
|
||||
import re
|
||||
import shutil
|
||||
|
|
@ -24,7 +23,6 @@ from pre_commit.languages import rust
|
|||
from pre_commit.repository import Repository
|
||||
from pre_commit.util import cmd_output
|
||||
from testing.fixtures import config_with_local_hooks
|
||||
from testing.fixtures import git_dir
|
||||
from testing.fixtures import make_config_from_repo
|
||||
from testing.fixtures import make_repo
|
||||
from testing.fixtures import modify_manifest
|
||||
|
|
@ -96,17 +94,14 @@ def test_python_hook_args_with_spaces(tempdir_factory, store):
|
|||
)
|
||||
|
||||
|
||||
def test_python_hook_weird_setup_cfg(tempdir_factory, store):
|
||||
path = git_dir(tempdir_factory)
|
||||
with cwd(path):
|
||||
with io.open('setup.cfg', 'w') as setup_cfg:
|
||||
setup_cfg.write('[install]\ninstall_scripts=/usr/sbin\n')
|
||||
def test_python_hook_weird_setup_cfg(in_git_dir, tempdir_factory, store):
|
||||
in_git_dir.join('setup.cfg').write('[install]\ninstall_scripts=/usr/sbin')
|
||||
|
||||
_test_hook_repo(
|
||||
tempdir_factory, store, 'python_hooks_repo',
|
||||
'foo', [os.devnull],
|
||||
b"['" + five.to_bytes(os.devnull) + b"']\nHello World\n",
|
||||
)
|
||||
_test_hook_repo(
|
||||
tempdir_factory, store, 'python_hooks_repo',
|
||||
'foo', [os.devnull],
|
||||
b"['" + five.to_bytes(os.devnull) + b"']\nHello World\n",
|
||||
)
|
||||
|
||||
|
||||
@xfailif_no_venv
|
||||
|
|
@ -444,14 +439,12 @@ def _norm_pwd(path):
|
|||
)[1].strip()
|
||||
|
||||
|
||||
def test_cwd_of_hook(tempdir_factory, store):
|
||||
def test_cwd_of_hook(in_git_dir, tempdir_factory, store):
|
||||
# Note: this doubles as a test for `system` hooks
|
||||
path = git_dir(tempdir_factory)
|
||||
with cwd(path):
|
||||
_test_hook_repo(
|
||||
tempdir_factory, store, 'prints_cwd_repo',
|
||||
'prints_cwd', ['-L'], _norm_pwd(path) + b'\n',
|
||||
)
|
||||
_test_hook_repo(
|
||||
tempdir_factory, store, 'prints_cwd_repo',
|
||||
'prints_cwd', ['-L'], _norm_pwd(in_git_dir.strpath) + b'\n',
|
||||
)
|
||||
|
||||
|
||||
def test_lots_of_files(tempdir_factory, store):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue