GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — GitPython/test/test_remote_cli.py at main · gitpython-developers/GitPython Expand file tree/ Copy pathtest_remote_cli.pyMore file actions 72 lines (61 loc) · 2.81 KB / Copy pathtest_remote_cli.pyFile metadata and controls72 lines (61 loc) · 2.81 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 """Fetch and pull derive results exclusively from Git command output.""" import builtins import os from unittest import mock import pytest from git import FetchInfo, Repo from git.objects.submodule.util import sm_section from test.lib.fixtures import writable_fixture @pytest.fixture def remote_fixture(request): with writable_fixture("remote-cli.sh", *request.param) as temporary: yield temporary.path().resolve() @pytest.mark.parametrize( "remote_fixture", [("fetch", obj, refs) for obj in ("sha1", "sha256") for refs in ("files", "reftable")], indirect=True, ) def test_fetch_and_pull_without_reading_fetch_head(remote_fixture): source = Repo(remote_fixture / "source") branch = source.active_branch.name clone = Repo(remote_fixture / "clone") old = clone.head.commit expected = source.head.commit original_open = builtins.open def checked_open(path, *args, **kwargs): if isinstance(path, (str, os.PathLike)): assert os.path.basename(path) != "FETCH_HEAD", "Python must not read FETCH_HEAD" return original_open(path, *args, **kwargs) with mock.patch("builtins.open", side_effect=checked_open): result = clone.remote().fetch() info = result["origin/" + branch] assert info.old_commit == old assert info.commit == expected assert info.flags & FetchInfo.FAST_FORWARD assert info.remote_ref_path == branch assert isinstance(info.note, str) single = clone.remote().fetch(branch) assert len(single) == 1 assert single[0].ref.path == "FETCH_HEAD" assert single[0].commit == expected clone.remote().pull(ff_only=True) assert clone.head.commit == expected source.close() clone.close() @pytest.mark.parametrize("remote_fixture", [("quoted",)], indirect=True) def test_quoted_remote_and_submodule_names(remote_fixture): tmp_path = remote_fixture with Repo(tmp_path / "source"), Repo(tmp_path / "parent") as parent: remote = parent.create_remote('quoted"remote', str(tmp_path / "source")) assert parent.remote(remote.name).url == remote.url assert remote.config_reader.get_value("url") == (tmp_path / "source").as_posix() # Keep the quoted name in config: Windows cannot represent it in metadata. with Repo.clone_from(str(tmp_path / "source"), tmp_path / "parent" / "module"): module = parent.create_submodule("module", "module") quoted_name = 'quoted"module' with module.config_writer() as writer: writer.config.rename_section(sm_section(module.name), sm_section(quoted_name)) parent.index.commit("Add module") module = parent.submodules[0] assert module.name == quoted_name assert module.config_reader().get_value("url") == (tmp_path / "source").as_posix() |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |