analytics: don't verify config from repo

Otherwise this will raise an exception from analytics worker:
```
dvc config cache.type sometypo
```
But running that same command with `--system` or `--global` flag outside
of repo won't raise that.

Also need to better handle ConfigObjError, but that is a separate issue.
This commit is contained in:
Ruslan Kuprieiev
2019-11-08 02:37:11 +02:00
parent 7387760755
commit 910a67b35f
2 changed files with 17 additions and 3 deletions
+3 -3
View File
@@ -219,10 +219,10 @@ class Analytics(object):
try:
dvc_dir = Repo.find_dvc_dir()
config = Config(dvc_dir)
except NotDvcRepoError:
config = Config(validate=False)
return config
dvc_dir = None
return Config(dvc_dir, validate=False)
@staticmethod
def is_enabled(cmd=None):
+14
View File
@@ -0,0 +1,14 @@
from dvc.analytics import Analytics
from dvc.config import Config
from dvc.repo import NotDvcRepoError
def test_broken_config(mocker, dvc_repo):
Config(dvc_repo.dvc_dir, validate=False).set("cache", "type", "unknown")
assert Analytics._get_current_config()
with mocker.patch(
"dvc.repo.Repo.find_dvc_dir", side_effect=NotDvcRepoError(".")
):
assert Analytics._get_current_config()