dvc: stop trying to fetch from remote when looking for git object (#2241)

Closes #2213
This commit is contained in:
Alexander Schepanovski
2019-07-08 17:57:25 +03:00
committed by Ruslan Kuprieiev
parent d0299b3edf
commit 14ce9d6d4a
-20
View File
@@ -78,32 +78,12 @@ class GitTree(BaseTree):
return True
return False
def _try_fetch_from_remote(self):
import git
try:
# checking if tag/branch exists locally
self.git.git.show_ref(self.rev, verify=True)
return
except git.exc.GitCommandError:
pass
try:
# checking if it exists on the remote
self.git.git.ls_remote("origin", self.rev, exit_code=True)
# fetching remote tag/branch so we can reference it locally
self.git.git.fetch("origin", "{rev}:{rev}".format(rev=self.rev))
except git.exc.GitCommandError:
pass
def git_object_by_path(self, path):
import git
path = relpath(os.path.realpath(path), self.git.working_dir)
assert path.split(os.sep, 1)[0] != ".."
self._try_fetch_from_remote()
try:
tree = self.git.tree(self.rev)
except git.exc.BadName as exc: