mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-20 18:59:07 -05:00
fix: a truncated tree does not prove a file gone
When the forge truncates the HEAD tree, the rename search cannot see every path, yet a bare filename it did not find was reported GONE. eden's fs_paths.h and path_util.cpp exist under src/common/fs/. Such a citation is now AMBIGUOUS with the reason, as the realign path already says unclear and never absent.
This commit is contained in:
1 parent
d62ada2e6e
commit
6bfd73f4f8
2 files changed
+31
No files matched your search
@@ -873,6 +873,12 @@ def _written_against_head(part: RefPart, head_lines: list[str] | None) -> bool:
|
||||
)
|
||||
|
||||
|
||||
# What the rename search answers when a tree it needed came back truncated:
|
||||
# a file missing from a partial listing may still exist, so absence is not
|
||||
# established. eden's fs_paths.h and path_util.cpp were reported GONE.
|
||||
TREE_TRUNCATED = "(HEAD tree truncated by the forge)"
|
||||
|
||||
|
||||
def anchor_part(
|
||||
part: RefPart,
|
||||
fetch: Callable[[str, str, int | None, Sequence[str]], list[str] | None],
|
||||
@@ -906,6 +912,13 @@ def anchor_part(
|
||||
if head_lines is None:
|
||||
moved, candidates = rename_getter(part.path)
|
||||
if moved is None:
|
||||
if candidates == [TREE_TRUNCATED]:
|
||||
return PartResult(
|
||||
part, "AMBIGUOUS", None, None, None, [],
|
||||
"absent from a HEAD tree the forge truncated: "
|
||||
"the file may still exist",
|
||||
slug, url,
|
||||
)
|
||||
if candidates:
|
||||
return PartResult(
|
||||
part,
|
||||
@@ -1579,6 +1592,7 @@ def build_report(
|
||||
|
||||
owners: dict[tuple[str, int | None], tuple[RepoView, str]] = {}
|
||||
context: dict[str, object] = {}
|
||||
truncated_trees: set[str] = set()
|
||||
pin_trees: dict[str, list[str] | None] = {}
|
||||
|
||||
def _locate(
|
||||
@@ -1745,6 +1759,8 @@ def build_report(
|
||||
view.repo, view.head, cache_dir, offline
|
||||
)
|
||||
context[key] = (comparison, tree)
|
||||
if truncated:
|
||||
truncated_trees.add(key)
|
||||
if truncated and tree:
|
||||
print(
|
||||
f"{name}: {key} HEAD tree truncated by the forge, "
|
||||
@@ -1772,6 +1788,8 @@ def build_report(
|
||||
# across repositories turns a resolvable path into an ambiguous one.
|
||||
if view is owner:
|
||||
candidates = near
|
||||
if not candidates and any(v.repo.slug in truncated_trees for v in ordered):
|
||||
return None, [TREE_TRUNCATED]
|
||||
return None, candidates
|
||||
|
||||
# Pin trees before HEAD trees, each read only when reached.
|
||||
|
||||
@@ -1245,6 +1245,19 @@ class TestBuildReport(unittest.TestCase):
|
||||
self.assertEqual(statuses, ["UNCHECKED"])
|
||||
self.assertIn("refused", report.entries[0].parts[0].reason)
|
||||
|
||||
def test_a_truncated_head_tree_is_not_an_absence(self):
|
||||
"""git.eden-emu.dev truncates the HEAD tree: fs_paths.h, cited bare,
|
||||
was reported GONE though it lives under src/common/fs/."""
|
||||
self.files[("pinsha", "fs_paths.h")] = ["x", "hit"]
|
||||
profile_sync.upstream.list_tree = (
|
||||
lambda repo, sha, cache_dir, offline=False: (["other.c"], True)
|
||||
)
|
||||
with contextlib.redirect_stderr(io.StringIO()):
|
||||
report = build_report("test", self._profile(["fs_paths.h:2"]), self.dir)
|
||||
part = report.entries[0].parts[0]
|
||||
self.assertEqual(part.status, "AMBIGUOUS")
|
||||
self.assertIn("truncated", part.reason)
|
||||
|
||||
def test_counts_by_status(self):
|
||||
self.files[("pinsha", "a.c")] = ["x", "hit", "y"]
|
||||
self.files[("headsha", "a.c")] = ["pad", "x", "hit", "y"]
|
||||
|
||||
Reference in new issue
Block a user