hooks: checkout: fix incorrect dvc repo detection

When running from non-root directory `git ls-files .dvc` will treat it
as a relative path to the current location, so if you run `git checkout`
from a directory that is not a git/dvc root, our hook will think that
it is being run in a non-dvc repo and will do nothing. To fix that, need
to use `--full-name` flag.
This commit is contained in:
Ruslan Kuprieiev
2020-01-23 10:21:26 +02:00
parent da6399dc3c
commit f6f931be87
+1 -1
View File
@@ -250,7 +250,7 @@ class Git(Base):
def _install_hook(self, name, cmd):
command = (
'[ "$3" = "0" ]'
' || [ -z "$(git ls-files .dvc)" ]'
' || [ -z "$(git ls-files --full-name .dvc)" ]'
" || exec dvc {}".format(cmd)
)