pkg: import git dynamically

This allows dvc to work even if there is no git present, as long as user
is not using `dvc pkg` command directly.

Fixes #1835

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2019-04-06 23:29:18 +03:00
parent 6105e5ead6
commit 5c008cfcb5
2 changed files with 4 additions and 3 deletions
+2 -1
View File
@@ -2,7 +2,6 @@ from __future__ import unicode_literals
import os
import shutil
from git.cmd import Git
import dvc.logger as logger
from dvc.exceptions import DvcException
@@ -60,6 +59,8 @@ class GitPackage(Package):
DEF_DVC_FILE_PREFIX = "mod_"
def install_or_update(self, parent_repo, pkg_params):
from git.cmd import Git
if not self.is_in_root():
raise DvcException(
"This command can be run only from a repository root"
+2 -2
View File
@@ -2,8 +2,6 @@ import os
import shutil
import tempfile
import git
from dvc import logger
from dvc.exceptions import DvcException
@@ -70,6 +68,8 @@ class TempGitRepo(object):
return self
def _clone_to_temp_dir(self):
import git
result = tempfile.mktemp(
prefix=self._tmp_mod_prefix, dir=self.modules_dir
)