def test_push_wildcard_from_bare_git_repo(tmp_dir, make_tmp_dir, erepo_dir, local_cloud): Git.init(tmp_dir.fs_path, bare=True).close() erepo_dir.add_remote(config=local_cloud.config) with erepo_dir.chdir(): erepo_dir.dvc_gen( { "dir123": { "foo": "foo content" }, "dirextra": { "extrafoo": "extra foo content" }, }, commit="initial", ) erepo_dir.dvc.push([os.path.join(os.fspath(erepo_dir), "dire*")], glob=True) erepo_dir.scm.gitpython.repo.create_remote("origin", os.fspath(tmp_dir)) erepo_dir.scm.gitpython.repo.remote("origin").push("master") dvc_repo = make_tmp_dir("dvc-repo", scm=True, dvc=True) with dvc_repo.chdir(): dvc_repo.dvc.imp(os.fspath(tmp_dir), "dirextra") with pytest.raises(PathMissingError): dvc_repo.dvc.imp(os.fspath(tmp_dir), "dir123")
def test_import_from_bare_git_repo(tmp_dir, make_tmp_dir, erepo_dir, local_cloud): Git.init(tmp_dir.fs_path, bare=True).close() erepo_dir.add_remote(config=local_cloud.config) with erepo_dir.chdir(): erepo_dir.dvc_gen({"foo": "foo"}, commit="initial") erepo_dir.dvc.push() erepo_dir.scm.gitpython.repo.create_remote("origin", os.fspath(tmp_dir)) erepo_dir.scm.gitpython.repo.remote("origin").push("master") dvc_repo = make_tmp_dir("dvc-repo", scm=True, dvc=True) with dvc_repo.chdir(): dvc_repo.dvc.imp(os.fspath(tmp_dir), "foo")
def test_no_commits(tmp_dir): from scmrepo.git import Git from dvc.repo import Repo git = Git.init(tmp_dir.fs_path) assert git.no_commits assert Repo.init().metrics.diff() == {}
def init(self, *, scm=False, dvc=False, subdir=False): from scmrepo.git import Git from dvc.repo import Repo assert not scm or not hasattr(self, "scm") assert not dvc or not hasattr(self, "dvc") if scm: Git.init(self.fs_path).close() if dvc: self.dvc = Repo.init( self.fs_path, no_scm=not scm and not hasattr(self, "scm"), subdir=subdir, ) if scm: self.scm = (self.dvc.scm if hasattr(self, "dvc") else Git(self.fs_path)) if dvc and hasattr(self, "scm"): self.scm.commit("init dvc")
def setUp(self): from scmrepo.git import Git super().setUp() self.git = Git.init(".") self.git.add_commit(self.CODE, message="add code")