Making it possible to invoke pre-commit run --files some.file from a subdirectory of the repository

This commit is contained in:
Lucas Cimon 2016-02-03 09:03:59 +01:00 committed by Anthony Sottile
parent 894862462d
commit 941149942d
3 changed files with 11 additions and 3 deletions

View file

@ -83,7 +83,8 @@ def _do_run(repo, args, environ={}):
runner = Runner(repo)
write_mock = mock.Mock()
write_fn = functools.partial(sys_stdout_write_wrapper, stream=write_mock)
ret = run(runner, args, write=write_fn, environ=environ)
with cwd(runner.git_root): # replicates Runner.create behaviour
ret = run(runner, args, write=write_fn, environ=environ)
printed = get_write_mock_output(write_mock)
return ret, printed