mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-13 20:40:08 -06:00
Add regression test for #339.
This commit is contained in:
@@ -596,3 +596,26 @@ def test_unstaged_message_suppressed(
|
||||
args = _get_opts(**opts)
|
||||
ret, printed = _do_run(modified_config_repo, args)
|
||||
assert b'Your .pre-commit-config.yaml is unstaged.' not in printed
|
||||
|
||||
|
||||
def test_files_running_subdir(
|
||||
repo_with_passing_hook, mock_out_store_directory, tempdir_factory,
|
||||
):
|
||||
with cwd(repo_with_passing_hook):
|
||||
install(Runner(repo_with_passing_hook))
|
||||
|
||||
os.mkdir('subdir')
|
||||
open('subdir/foo.py', 'w').close()
|
||||
cmd_output('git', 'add', 'subdir/foo.py')
|
||||
|
||||
with cwd('subdir'):
|
||||
# Don't want to write to home directory
|
||||
env = dict(os.environ, PRE_COMMIT_HOME=tempdir_factory.get())
|
||||
# Use subprocess to demonstrate behaviour in main
|
||||
_, stdout, _ = cmd_output(
|
||||
sys.executable, '-m', 'pre_commit.main', 'run', '-v',
|
||||
# Files relative to where we are (#339)
|
||||
'--files', 'foo.py',
|
||||
env=env,
|
||||
)
|
||||
assert 'subdir/foo.py' in stdout
|
||||
|
||||
Reference in New Issue
Block a user