Update, repo tool cloner: recursive clones

Signed-off-by: Václav Valíček <valicek1994@gmail.com>
This commit is contained in:
2022-07-29 17:03:15 +02:00
parent 8a150c63c5
commit 6463a6bb95
6 changed files with 142 additions and 65 deletions

View File

@@ -79,12 +79,33 @@ def test_bare(tmp_path, monkeypatch):
def test_path(tmp_path, monkeypatch):
rt = RepoTool(tmp_path)
rt = RepoTool(tmp_path.as_posix())
assert tmp_path.as_posix() == rt.path
monkeypatch.setattr(rt, "_path", "/tmp")
assert "/tmp" == rt.path
def test_cloned_submodules_url_list(tmp_path, monkeypatch):
rt = RepoTool(tmp_path.as_posix())
assert rt.cloned_submodules_url_list == []
monkeypatch.setattr(rt, "_recursive_discovery_cloned", {"https://repo.git/1", "git@hosting:/name/repo.git"})
assert rt.cloned_submodules_url_list == list({"https://repo.git/1", "git@hosting:/name/repo.git"})
def test_discovered_submodules_commits(tmp_path, monkeypatch):
commits = [
'a22b74fba976631f123d4b2348aba531cf6430fd',
'b1b0554e60fc5f0feb542bf54d1cadbc1d0418d6',
'd0c808ab0fc075497cb50d9c704b024bcc6cfa95',
'f8e168561a824da72f7d441932e77f3912039f9a,',
'8a150c63c5b688f39db15769db5c7d7c0fd52349',
]
rt = RepoTool(tmp_path.as_posix())
assert rt.discovered_submodules_commits == []
monkeypatch.setattr(rt, "_submodule_discovery_history", commits)
assert rt.discovered_submodules_commits == commits
def test_clone_initialized_repo(tmp_path, caplog, support_data_path):
from git import Repo
# initialize repo
@@ -423,6 +444,7 @@ def test_fingerprint(support_data_path: Path, repo: str, hash):
def test_list_submodules_no_submodules(cloned_base_repo_obj):
assert cloned_base_repo_obj.list_submodules() == []
assert cloned_base_repo_obj.discovered_submodules_commits == ["e0c7e2a72579e24657c05e875201011d2b48bf94"]
def test_list_submodules_ok(tmp_path, support_data_path):
@@ -435,6 +457,12 @@ def test_list_submodules_ok(tmp_path, support_data_path):
'https://git.sw3.cz/kamikaze/test-repo-reduced.git'
]
assert rt.cloned_submodules_url_list == []
assert rt.discovered_submodules_commits == [
'1946eeb4dda03473e796a8cc78b1946fc85df0fd',
'cc58d514348d0d2c8f0b75ad1f7ff96eb02781d5',
]
def test_list_submodules_history(tmp_path, support_data_path):
rt = RepoTool(tmp_path.joinpath("repo.git").as_posix())
@@ -457,6 +485,8 @@ def test_list_submodules_history(tmp_path, support_data_path):
'https://git.sw3.cz/kamikaze/test-repo-reduced.git',
]
assert len(rt.discovered_submodules_commits) == 645
def test_list_submodules_history_progress(support_data_path, caplog, monkeypatch):
mocked_time = 1659059078
@@ -478,3 +508,5 @@ def test_list_submodules_history_progress(support_data_path, caplog, monkeypatch
regex = re.compile("Submodule discovery: \\d+ commits finished, 1 discovered")
assert 8 == len(caplog.records)
assert 7 == sum(1 if regex.match(x.message) else 0 for x in caplog.records)
assert len(rt.discovered_submodules_commits) == 22