From de448bb77834283dec1f48c9e216eaa0b359f262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=B0=B8=E8=B5=AB?= <1259085392@qq.com> Date: Mon, 2 Nov 2026 01:01:20 +0900 Subject: [PATCH 1/2] feat: trace Project release ancestry --- scripts/sync_github_project.py | 16 +++++++++++++++- tests/test_project_delivery.py | 7 ++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/scripts/sync_github_project.py b/scripts/sync_github_project.py index 7b93e561c30..47a9cf95e43 100644 --- a/scripts/sync_github_project.py +++ b/scripts/sync_github_project.py @@ -6,6 +6,7 @@ import re import subprocess import sys +import time import urllib.error import urllib.request from functools import cache @@ -212,6 +213,12 @@ def tags_containing(commit): """ if not re.fullmatch(r"[0-9a-f]{40}", commit): raise ValueError("Invalid implementation commit") + started = time.monotonic() + print( + f"Project sync: release ancestry start commit={commit[:12]}", + file=sys.stderr, + flush=True, + ) result = subprocess.run( ["git", "tag", "--contains", commit], cwd=ROOT, @@ -224,7 +231,14 @@ def tags_containing(commit): raise RuntimeError( "Cannot verify release tag ancestry; fetch full history and tags" ) - return frozenset(result.stdout.splitlines()) + tags = frozenset(result.stdout.splitlines()) + print( + f"Project sync: release ancestry complete commit={commit[:12]} tags={len(tags)} " + f"seconds={time.monotonic() - started:.2f}", + file=sys.stderr, + flush=True, + ) + return tags def delivery(content, current, linked, releases, mainline): diff --git a/tests/test_project_delivery.py b/tests/test_project_delivery.py index 7d9d8d7e43c..a848f504ebe 100644 --- a/tests/test_project_delivery.py +++ b/tests/test_project_delivery.py @@ -339,7 +339,10 @@ def git(*args): (root / "file").write_text("release three") git("commit", "-am", "release three") git("tag", "v3") - with patch.object(sync, "ROOT", root): + with ( + patch.object(sync, "ROOT", root), + patch("sys.stderr", new_callable=io.StringIO) as output, + ): sync.tag_names.cache_clear() sync.tags_containing.cache_clear() self.assertEqual(sync.tags_containing(base), {"v1", "v2", "v3"}) @@ -370,6 +373,8 @@ def git(*args): ], "v2", ) + self.assertIn("release ancestry start", output.getvalue()) + self.assertIn("release ancestry complete", output.getvalue()) def test_tag_containment_failure_fails_closed(self): sync.tags_containing.cache_clear() From 02657a3fd361631377a20109039409306ba3f8fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=B0=B8=E8=B5=AB?= <1259085392@qq.com> Date: Mon, 2 Nov 2026 01:22:20 +0900 Subject: [PATCH 2/2] test: assert ancestry diagnostic details --- tests/test_project_delivery.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_project_delivery.py b/tests/test_project_delivery.py index a848f504ebe..cc457668822 100644 --- a/tests/test_project_delivery.py +++ b/tests/test_project_delivery.py @@ -375,6 +375,9 @@ def git(*args): ) self.assertIn("release ancestry start", output.getvalue()) self.assertIn("release ancestry complete", output.getvalue()) + self.assertIn(f"commit={second[:12]}", output.getvalue()) + self.assertRegex(output.getvalue(), r"tags=\d+") + self.assertRegex(output.getvalue(), r"seconds=\d+\.\d{2}") def test_tag_containment_failure_fails_closed(self): sync.tags_containing.cache_clear()