fix: don't dvc checkout on git file checkout

Closes #2400
This commit is contained in:
Gunnlaugur Thor Briem
2019-08-16 22:11:16 +00:00
parent d32515c969
commit e1dd75edcd
2 changed files with 11 additions and 3 deletions
+5 -1
View File
@@ -216,7 +216,11 @@ class Git(Base):
return [t.name for t in self.repo.tags]
def _install_hook(self, name, cmd):
command = '[ -z "$(git ls-files .dvc)" ] || exec dvc {}'.format(cmd)
command = (
'[ "$3" == "0" ]'
' || [ -z "$(git ls-files .dvc)" ]'
" || exec dvc {}".format(cmd)
)
hook = os.path.join(self.root_dir, self.GIT_DIR, "hooks", name)
+6 -2
View File
@@ -39,7 +39,9 @@ class TestInstall(object):
expected_script = (
"#!/bin/sh\n"
"echo hello\n"
'[ -z "$(git ls-files .dvc)" ] || exec dvc checkout\n'
'[ "$3" == "0" ]'
' || [ -z "$(git ls-files .dvc)" ]'
" || exec dvc checkout\n"
)
with open(self._hook("post-checkout"), "r") as fobj:
@@ -51,7 +53,9 @@ class TestInstall(object):
expected_script = (
"#!/bin/sh\n"
'[ -z "$(git ls-files .dvc)" ] || exec dvc checkout\n'
'[ "$3" == "0" ]'
' || [ -z "$(git ls-files .dvc)" ]'
" || exec dvc checkout\n"
)
with open(self._hook("post-checkout"), "r") as fobj: