diff --git a/dvc/scm/git/__init__.py b/dvc/scm/git/__init__.py index 41eef55a6..f852d0713 100644 --- a/dvc/scm/git/__init__.py +++ b/dvc/scm/git/__init__.py @@ -265,6 +265,9 @@ class Git(Base): ], } + if "repos" not in config: + config["repos"] = [] + if entry not in config["repos"]: config["repos"].append(entry) diff --git a/tests/func/test_install.py b/tests/func/test_install.py index 345183dec..5f0517523 100644 --- a/tests/func/test_install.py +++ b/tests/func/test_install.py @@ -30,6 +30,12 @@ class TestInstall: assert hook_path.is_file() assert command in hook_path.read_text() + def test_install_pre_commit_tool(self, scm): + scm.install(use_pre_commit_tool=True) + + precommit_path = pathlib.Path(".") / ".pre-commit-config.yaml" + assert precommit_path.is_file() + def test_fail_if_hook_exists(self, scm): self._hook("post-checkout").write_text("hook content")