| author | |
| committer | |
| log | 2532a0bae3c550f509e7d8945df1357b8639ef01 |
| tree | 25449f65cdc0fb098f5b8ef68235b37070f5aeed |
| parent | bc5fc51efa42a982c642c7aa79b021613e8e4e4a |
| signature | Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU |
Keep development navigation on unreleased versions and build pages. Migrate existing release introductions while preserving custom tables, notes, and timestamps.
Assisted-by: gpt-6.1-sol3 files changed, 29 insertions(+), 17 deletions(-)
service/zig-mirror/build/mirror.py+6-5| ... | ... | @@ -184,9 +184,7 @@ def version_readme(version, artifacts, development=False): |
| 184 | 184 | lines.append(f'- [{label}]({url})') |
| 185 | 185 | if lines[-1]: |
| 186 | 186 | lines.append('') |
| 187 | if development: | |
| 188 | lines += [f'[Development builds](/mirrors/zig/{version}/dev/)', ''] | |
| 189 | elif '-dev.' in version: | |
| 187 | if '-dev.' in version: | |
| 190 | 188 | lines += [f'[All development builds](/mirrors/zig/{version.split("-")[0]}/dev/)', ''] |
| 191 | 189 | if not artifacts: |
| 192 | 190 | return '\n'.join(lines).encode() |
| ... | ... | @@ -414,8 +412,11 @@ class Mirror: |
| 414 | 412 | for url in re.findall(r'''(?:href=["']|\]\()([^"')\s]+)''', previous.decode())} |
| 415 | 413 | linked = {name for name in present if PATTERN.fullmatch(name)} |
| 416 | 414 | introduction = content.split(b'<div ', 1)[0] |
| 417 | if artifacts and linked == required and previous.startswith(introduction) and b'https://file.paperclover.net' not in previous: | |
| 418 | return None | |
| 415 | preserved = previous | |
| 416 | if '-dev.' not in directory.name: | |
| 417 | preserved = preserved.replace(f'\n[Development builds](/mirrors/zig/{directory.name}/dev/)\n'.encode(), b'') | |
| 418 | if artifacts and linked == required and preserved.startswith(introduction) and b'https://file.paperclover.net' not in preserved: | |
| 419 | content = preserved | |
| 419 | 420 | if previous == content: |
| 420 | 421 | return None |
| 421 | 422 | return {'path': str(path.relative_to(self.root)), 'before': before, |
tools/zig-mirror-test.py+15-5| ... | ... | @@ -271,6 +271,7 @@ class MirrorTests(unittest.TestCase): |
| 271 | 271 | self.assertEqual(self.cache.root.stat().st_mtime_ns, stamp) |
| 272 | 272 | self.assertFalse(list(self.cache.root.rglob('.download-*'))) |
| 273 | 273 | self.assertIn('Signature for '+name, (artifact.parent/'preadme.md').read_text()) |
| 274 | self.assertIn('[All development builds](/mirrors/zig/0.18.0/dev/)', (artifact.parent/'preadme.md').read_text()) | |
| 274 | 275 | self.assertIn('this release only has [development builds]', (artifact.parent.parent.parent/'preadme.md').read_text()) |
| 275 | 276 | |
| 276 | 277 | @unittest.skipUnless(ctypes.util.find_library('sodium'), 'libsodium required') |
| ... | ... | @@ -381,8 +382,8 @@ class MirrorTests(unittest.TestCase): |
| 381 | 382 | self.assertNotIn(f'[{labels[key]}]({url})', text) |
| 382 | 383 | else: |
| 383 | 384 | self.assertIn(f'- [{labels[key]}]({url})', text) |
| 384 | self.assertLess(text.index(url), text.index('[Development builds]')) | |
| 385 | self.assertLess(text.index('[Development builds]'), text.index('<div ')) | |
| 385 | self.assertLess(text.index(url), text.index('<div ')) | |
| 386 | self.assertNotIn('[Development builds]', text) | |
| 386 | 387 | with patch.object(mirror, 'index', return_value={'0.19.0': {'notes': 'https://example.org/notes', 'docs': None, 'stdDocs': 'https://ziglang.org/bad)link'}}): |
| 387 | 388 | text = mirror.version_readme('0.19.0', [artifact]).decode() |
| 388 | 389 | for label in labels.values(): |
| ... | ... | @@ -393,17 +394,26 @@ class MirrorTests(unittest.TestCase): |
| 393 | 394 | artifact = self.cache.path('zig-x86_64-linux-0.17.0.tar.xz') |
| 394 | 395 | artifact.parent.mkdir() |
| 395 | 396 | artifact.write_bytes(b'already verified archive') |
| 397 | (artifact.parent / 'dev').mkdir() | |
| 396 | 398 | stamp = mirror.stable_time('0.17.0') |
| 397 | 399 | for path in [artifact, artifact.parent, self.cache.root]: |
| 398 | 400 | mirror.set_mtime(path, stamp) |
| 399 | self.cache.write_readmes(artifact.parent) | |
| 401 | release = {'date': '2026-10-01', 'docs': 'https://ziglang.org/documentation/0.17.0/', | |
| 402 | 'src': {'tarball': mirror.upstream(artifact.name), 'shasum': 'unused-cached-hash'}} | |
| 403 | with patch.object(mirror, 'index', return_value={'0.17.0': release}): | |
| 404 | self.cache.write_readmes(artifact.parent) | |
| 400 | 405 | mirror.set_mtime(artifact.parent, stamp) |
| 401 | 406 | readme = artifact.parent / 'preadme.md' |
| 407 | custom = readme.read_text().replace('| Architecture |', '| Target |') + '\nCustom table notes.\n' | |
| 408 | readme.write_text(custom.replace('<div ', '[Development builds](/mirrors/zig/0.17.0/dev/)\n\n<div ', 1)) | |
| 409 | with patch.object(mirror, 'index', return_value={'0.17.0': release}): | |
| 410 | change = self.cache.directory_readme(artifact.parent) | |
| 411 | self.assertEqual(mirror.base64.b64decode(change['previous']), readme.read_bytes()) | |
| 402 | 412 | original = {path: path.stat().st_mtime_ns for path in [artifact, artifact.parent, self.cache.root, readme]} |
| 403 | release = {'date': '2026-10-01', 'docs': 'https://ziglang.org/documentation/0.17.0/', | |
| 404 | 'src': {'tarball': mirror.upstream(artifact.name), 'shasum': 'unused-cached-hash'}} | |
| 405 | 413 | with patch.object(mirror, 'index', return_value={'0.17.0': release, 'master': {}}) as metadata, patch.object(mirror, 'fetch', side_effect=AssertionError('cached refresh must not redownload')): |
| 406 | 414 | self.cache.refresh() |
| 415 | self.assertNotIn('[Development builds]', readme.read_text()) | |
| 416 | self.assertEqual(readme.read_text(), custom) | |
| 407 | 417 | self.assertIn('[Language Reference](' + release['docs'] + ')', readme.read_text()) |
| 408 | 418 | self.assertIsNone(self.cache.directory_readme(artifact.parent)) |
| 409 | 419 | metadata.assert_any_call(refresh=True) |
tools/zig-mirror.md+8-7| ... | ... | @@ -46,13 +46,14 @@ refresh bypasses it, as does a cache miss for an unindexed stable version's date |
| 46 | 46 | Refresh also updates the current release/build navigation when archives are |
| 47 | 47 | already cached, preserving artifact and folder dates. |
| 48 | 48 | |
| 49 | Base versions link to their development index; a base folder with only development | |
| 50 | builds says “this release only has development builds out.” Each development | |
| 51 | version links back to its index, whose heading leaves the native directory listing | |
| 52 | to show the builds. Complete existing relative-link tables are retained when | |
| 53 | their introduction matches the published links and navigation; incomplete or | |
| 54 | production-only links are replaced. The owner's root `preadme.md` and hidden | |
| 55 | history remain untouched. | |
| 49 | Released base versions show their artifacts without a development-build link; a | |
| 50 | base folder with only development builds says “this release only has development | |
| 51 | builds out.” Each development version links back to its index, whose heading | |
| 52 | leaves the native directory listing to show the builds. Complete existing | |
| 53 | relative-link tables are retained when their introduction matches the published | |
| 54 | links and navigation, removing the old standalone development-build link from | |
| 55 | released pages; incomplete or production-only links are replaced. The owner's | |
| 56 | root `preadme.md` and hidden history remain untouched. | |
| 56 | 57 | |
| 57 | 58 | Existing verified archives need a one-time metadata reconciliation. It reads |
| 58 | 59 | signature comments and file metadata, not archive bodies, and preserves atime, |