repo: try to support opening uninitialized/broken repositories (#10736)

This `_get_remote_config()` should use `uninitialized=True` so that it supports
more broader kinds of broken/partially-initialized repositories, including some that have
`.dvc` directory missing, or `.git` directory missing.

This partially reverts #10719. #10608 is also fixed, and no longer requires `core.no_scm` to be passed.
This was already supported by `dvc.api.get_url` as it uses `uninitialized=True`, but this was not respected
in `_get_remote_config()` where it would fail before.

That said, this whole `open_repo`/`_get_remote_config` is terribly broken. For one, it is opening
a local repository, and forcing it's remote config to a repository opened with `Repo(rev=...)`,
where the config may be different.
This commit is contained in:
skshetry
2025-05-06 08:39:23 +00:00
committed by GitHub
parent f3be7d761f
commit 415d4bc980
2 changed files with 15 additions and 29 deletions
+2 -6
View File
@@ -5,7 +5,7 @@ from funcy import first, get_in
from dvc import api
from dvc.exceptions import OutputNotFoundError, PathMissingError
from dvc.scm import CloneError, SCMError
from dvc.scm import CloneError
from dvc.testing.api_tests import TestAPI # noqa: F401
from dvc.testing.tmp_dir import make_subrepo
from dvc.utils.fs import remove
@@ -79,11 +79,7 @@ def test_get_url_ignore_scm(tmp_dir, dvc, cloud, scm):
# Simulate gitless environment (e.g. deployed container)
(tmp_dir / ".git").rename(tmp_dir / "gitless_environment")
# Test failure mode when trying to access with git
with pytest.raises(SCMError, match="is not a git repository"):
api.get_url("foo", repo=repo_posix)
# Test successful access by ignoring git
assert api.get_url("foo", repo=repo_posix) == expected_url
assert (
api.get_url("foo", repo=repo_posix, config={"core": {"no_scm": True}})
== expected_url