Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a compat test case which verifies that shallow clones can be deep… #1458

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions tests/compat/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

from dulwich import client, file, index, objects, protocol, repo
from dulwich.porcelain import tag_create
from dulwich.protocol import DEPTH_INFINITE
from dulwich.refs import _import_remote_refs

from .. import SkipTest, expectedFailure
from .utils import (
Expand Down Expand Up @@ -155,6 +157,49 @@ def test_send_without_report_status(self) -> None:
)
self.assertDestEqualsSrc()

def test_fetch_into_shallow_clone(self) -> None:
c = self._client()
server_new_path = os.path.join(self.gitroot, "server_new.export")
run_git_or_fail(["config", "http.uploadpack", "true"], cwd=server_new_path)
run_git_or_fail(["config", "http.receivepack", "true"], cwd=server_new_path)
remote_path = self._build_path("/server_new.export")
with repo.Repo(self.dest) as local:
result = c.fetch(remote_path, local, depth=1)
self.assertEqual(
local.get_shallow(),
{
b"35e0b59e187dd72a0af294aedffc213eaa4d03ff",
b"514dc6d3fbfe77361bcaef320c4d21b72bc10be9",
},
)
for r in result.refs.items():
local.refs.set_if_equals(r[0], None, r[1])
with repo.Repo(os.path.join(self.gitroot, "server_new.export")) as src:
tree_id = src[src.head()].tree
for filename, contents in [
("bar", "bar contents"),
("zop", "zop contents"),
]:
tree_id = self._add_file(src, tree_id, filename, contents)
src.do_commit(
message=b"add " + filename.encode("utf-8"),
committer=b"Joe Example <[email protected]>",
tree=tree_id,
)
with repo.Repo(self.dest) as local:
result = c.fetch(remote_path, local, depth=DEPTH_INFINITE)
_import_remote_refs(
local.refs,
"origin",
result.refs,
f"fetch: from {remote_path}".encode("ascii"),
)
self.assertEqual(local.get_shallow(), set())
with repo.Repo(self.dest) as local:
tree = local[b"HEAD"].tree
tree = local[b"refs/remotes/origin/master"].tree
local.reset_index(tree=tree)

def make_dummy_commit(self, dest):
b = objects.Blob.from_string(b"hi")
dest.object_store.add_object(b)
Expand Down
Loading