Compare commits

...
Author SHA1 Message Date
issue-fix-bot db5a9787ec fix: [alert] KubePodNotReady (ai) (#880)
ci/woodpecker/pr/ci-scripts-test Pipeline is pending
ci/woodpecker/pr/pr-review Pipeline is pending
ci/woodpecker/push/build-ci-images Pipeline was successful
2026-09-20 08:47:13 +00:00
2 changed files with 17 additions and 2 deletions
+14
View File
@@ -58,6 +58,20 @@ class ParseTests(unittest.TestCase):
self.assertFalse(wi.verify_signature("s3cret", body, ""))
class TreeTests(unittest.TestCase):
def test_paging_stops_on_null_page(self):
# Gitea clamps per_page, keeps `truncated` true while pages remain and answers
# `"tree": null` for the first page past the end.
pages = {1: {"truncated": True, "tree": [{"type": "blob", "path": "wiki/a.md", "sha": "a"}]},
2: {"truncated": True, "tree": [{"type": "blob", "path": "wiki/b.md", "sha": "b"},
{"type": "tree", "path": "wiki/sub", "sha": "d"},
{"type": "blob", "path": "wiki/sub/c.md", "sha": "c"}]},
3: {"truncated": True, "tree": None}}
g = wi.Gitea("tok")
g.api = lambda path, **params: pages[params["page"]]
self.assertEqual(g.tree("c1"), {"wiki/a.md": "a", "wiki/b.md": "b"})
class FakeGitea:
def __init__(self, head, tree, files):
self._head, self._tree, self.files = head, tree, files
+3 -2
View File
@@ -123,11 +123,12 @@ class Gitea:
page = 1
while True:
t = self.api(f"/git/trees/{commit}", recursive="true", per_page=1000, page=page)
for e in t.get("tree", []):
entries = t.get("tree") or [] # Gitea clamps per_page and answers `"tree": null` past the last page
for e in entries:
p = e.get("path", "")
if e.get("type") == "blob" and p.startswith(WIKI_DIR + "/") and p.endswith(".md") and "/" not in p[len(WIKI_DIR) + 1:]:
out[p] = e["sha"]
if not t.get("truncated") and len(t.get("tree", [])) < 1000:
if not entries: # the only reliable end-of-tree signal: `truncated` stays true while pages remain
break
page += 1
if page > 50: