mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-25 15:28:49 +01:00
Moved remote_config_exists into RemoteConfig
This commit is contained in:
+2
-18
@@ -8,7 +8,7 @@ from funcy import retry
|
||||
|
||||
from dvc.exceptions import NoRemoteInExternalRepoError
|
||||
from dvc.remote import RemoteConfig
|
||||
from dvc.config import NoRemoteError, ConfigError
|
||||
from dvc.config import NoRemoteError
|
||||
from dvc.exceptions import NoOutputInExternalRepoError
|
||||
from dvc.exceptions import OutputNotFoundError
|
||||
from dvc.utils.fs import remove
|
||||
@@ -73,7 +73,7 @@ def _external_repo(url=None, rev=None, cache_dir=None):
|
||||
# add default remote pointing to the original repo's cache location
|
||||
if os.path.isdir(url):
|
||||
rconfig = RemoteConfig(repo.config)
|
||||
if not _remote_config_exists(rconfig):
|
||||
if not rconfig.remote_config_exists():
|
||||
original_repo = Repo(url)
|
||||
rconfig.add(
|
||||
"upstream",
|
||||
@@ -127,19 +127,3 @@ def _clone_repo(url, path):
|
||||
|
||||
git = Git.clone(url, path)
|
||||
git.close()
|
||||
|
||||
|
||||
def _remote_config_exists(rconfig):
|
||||
"""
|
||||
Checks if default remote config is present.
|
||||
Args:
|
||||
rconfig: a remote config
|
||||
|
||||
Returns:
|
||||
True if the remote config exists, else False
|
||||
"""
|
||||
try:
|
||||
default = rconfig.get_default()
|
||||
except ConfigError:
|
||||
default = None
|
||||
return bool(default)
|
||||
|
||||
@@ -156,3 +156,18 @@ class RemoteConfig(object):
|
||||
return self.config.get(
|
||||
Config.SECTION_CORE, Config.SECTION_CORE_REMOTE, level=level
|
||||
)
|
||||
|
||||
def remote_config_exists(self):
|
||||
"""
|
||||
Checks if default remote config is present.
|
||||
Args:
|
||||
rconfig: a remote config
|
||||
|
||||
Returns:
|
||||
True if the remote config exists, else False
|
||||
"""
|
||||
try:
|
||||
default = self.get_default()
|
||||
except ConfigError:
|
||||
default = None
|
||||
return bool(default)
|
||||
|
||||
Reference in New Issue
Block a user