mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
dvc: hooks only act in branches where dvc active (#2338)
* dvc: hooks only act in branches where dvc active In a branch where DVC hasn't been initialized (as detected by `git ls-files .dvc` not listing any files), don't invoke dvc in the git hooks. This avoids trouble when switching between branches with and without dvc initialized. Fixes #2208 * dvc: simplify hooks per PR comment
This commit is contained in:
committed by
Ruslan Kuprieiev
parent
df0359fad0
commit
e917ce0ae8
@@ -36,7 +36,11 @@ class TestInstall(object):
|
||||
|
||||
assert main(["install"]) == 0
|
||||
|
||||
expected_script = "#!/bin/sh\n" "echo hello\n" "exec dvc checkout\n"
|
||||
expected_script = (
|
||||
"#!/bin/sh\n"
|
||||
"echo hello\n"
|
||||
'[ -z "$(git ls-files .dvc)" ] || exec dvc checkout\n'
|
||||
)
|
||||
|
||||
with open(self._hook("post-checkout"), "r") as fobj:
|
||||
assert fobj.read() == expected_script
|
||||
@@ -45,7 +49,10 @@ class TestInstall(object):
|
||||
assert main(["install"]) == 0
|
||||
assert main(["install"]) == 0
|
||||
|
||||
expected_script = "#!/bin/sh\n" "exec dvc checkout\n"
|
||||
expected_script = (
|
||||
"#!/bin/sh\n"
|
||||
'[ -z "$(git ls-files .dvc)" ] || exec dvc checkout\n'
|
||||
)
|
||||
|
||||
with open(self._hook("post-checkout"), "r") as fobj:
|
||||
assert fobj.read() == expected_script
|
||||
|
||||
Reference in New Issue
Block a user