Skip to content
Merged
Show file tree
Hide file tree
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
16 changes: 15 additions & 1 deletion scripts/sync_github_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import re
import subprocess
import sys
import time
import urllib.error
import urllib.request
from functools import cache
Expand Down Expand Up @@ -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,
Expand All @@ -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):
Expand Down
10 changes: 9 additions & 1 deletion tests/test_project_delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"})
Expand Down Expand Up @@ -370,6 +373,11 @@ def git(*args):
],
"v2",
)
self.assertIn("release ancestry start", output.getvalue())
self.assertIn("release ancestry complete", output.getvalue())
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
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()
Expand Down
Loading