mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Allow try-repo to work on bare repositories
This commit is contained in:
parent
3a72fb39cb
commit
968b2fdaf1
2 changed files with 10 additions and 1 deletions
|
|
@ -141,7 +141,7 @@ def has_diff(*args, **kwargs):
|
||||||
repo = kwargs.pop('repo', '.')
|
repo = kwargs.pop('repo', '.')
|
||||||
assert not kwargs, kwargs
|
assert not kwargs, kwargs
|
||||||
cmd = ('git', 'diff', '--quiet', '--no-ext-diff') + args
|
cmd = ('git', 'diff', '--quiet', '--no-ext-diff') + args
|
||||||
return cmd_output_b(*cmd, cwd=repo, retcode=None)[0]
|
return cmd_output_b(*cmd, cwd=repo, retcode=None)[0] == 1
|
||||||
|
|
||||||
|
|
||||||
def has_core_hookpaths_set():
|
def has_core_hookpaths_set():
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,15 @@ def test_try_repo_relative_path(cap_out, tempdir_factory):
|
||||||
assert not try_repo(try_repo_opts(relative_repo, hook='bash_hook'))
|
assert not try_repo(try_repo_opts(relative_repo, hook='bash_hook'))
|
||||||
|
|
||||||
|
|
||||||
|
def test_try_repo_bare_repo(cap_out, tempdir_factory):
|
||||||
|
repo = make_repo(tempdir_factory, 'modified_file_returns_zero_repo')
|
||||||
|
with cwd(git_dir(tempdir_factory)):
|
||||||
|
_add_test_file()
|
||||||
|
bare_repo = os.path.join(repo, '.git')
|
||||||
|
# previously crashed attempting modification changes
|
||||||
|
assert not try_repo(try_repo_opts(bare_repo, hook='bash_hook'))
|
||||||
|
|
||||||
|
|
||||||
def test_try_repo_specific_revision(cap_out, tempdir_factory):
|
def test_try_repo_specific_revision(cap_out, tempdir_factory):
|
||||||
repo = make_repo(tempdir_factory, 'script_hooks_repo')
|
repo = make_repo(tempdir_factory, 'script_hooks_repo')
|
||||||
ref = git.head_rev(repo)
|
ref = git.head_rev(repo)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue