Skip to content

Commit

Permalink
dvc: stop trying to fetch from remote when looking for git object
Browse files Browse the repository at this point in the history
  • Loading branch information
Suor committed Jul 8, 2019
1 parent 7ad3c56 commit cc53ed2
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions dvc/scm/git/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,32 +78,12 @@ def _is_tree_and_contains(obj, path):
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:
Expand Down

0 comments on commit cc53ed2

Please sign in to comment.