mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Fix regression: try-repo from relative path
This commit is contained in:
parent
fbebd84494
commit
af93bec4fd
2 changed files with 14 additions and 1 deletions
|
|
@ -143,10 +143,12 @@ class Store(object):
|
||||||
def clone_strategy(directory):
|
def clone_strategy(directory):
|
||||||
env = no_git_env()
|
env = no_git_env()
|
||||||
|
|
||||||
|
cmd = ('git', 'clone', '--no-checkout', repo, directory)
|
||||||
|
cmd_output(*cmd, env=env)
|
||||||
|
|
||||||
def _git_cmd(*args):
|
def _git_cmd(*args):
|
||||||
return cmd_output('git', *args, cwd=directory, env=env)
|
return cmd_output('git', *args, cwd=directory, env=env)
|
||||||
|
|
||||||
_git_cmd('clone', '--no-checkout', repo, '.')
|
|
||||||
_git_cmd('reset', ref, '--hard')
|
_git_cmd('reset', ref, '--hard')
|
||||||
_git_cmd('submodule', 'update', '--init', '--recursive')
|
_git_cmd('submodule', 'update', '--init', '--recursive')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import os.path
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from pre_commit.commands.try_repo import try_repo
|
from pre_commit.commands.try_repo import try_repo
|
||||||
|
|
@ -69,3 +70,13 @@ def test_try_repo_with_specific_hook(cap_out, tempdir_factory):
|
||||||
config,
|
config,
|
||||||
)
|
)
|
||||||
assert rest == '[bash_hook] Bash hook................................(no files to check)Skipped\n' # noqa
|
assert rest == '[bash_hook] Bash hook................................(no files to check)Skipped\n' # noqa
|
||||||
|
|
||||||
|
|
||||||
|
def test_try_repo_relative_path(cap_out, tempdir_factory):
|
||||||
|
repo = make_repo(tempdir_factory, 'modified_file_returns_zero_repo')
|
||||||
|
with cwd(git_dir(tempdir_factory)):
|
||||||
|
open('test-file', 'a').close()
|
||||||
|
cmd_output('git', 'add', '.')
|
||||||
|
relative_repo = os.path.relpath(repo, '.')
|
||||||
|
# previously crashed on cloning a relative path
|
||||||
|
assert not try_repo(try_repo_opts(relative_repo, hook='bash_hook'))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue