authoravatarclover caruso<git@paperclover.net>2026-10-17 13:33:19-07:00
committeravatarclover caruso<git@paperclover.net>2026-10-21 02:52:29-07:00
log2532a0bae3c550f509e7d8945df1357b8639ef01
tree25449f65cdc0fb098f5b8ef68235b37070f5aeed
parentbc5fc51efa42a982c642c7aa79b021613e8e4e4a
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU

Remove duplicate development navigation from released Zig pages

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-sol

3 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,9 +184,7 @@ def version_readme(version, artifacts, development=False):
184 lines.append(f'- [{label}]({url})')184 lines.append(f'- [{label}]({url})')
185 if lines[-1]:185 if lines[-1]:
186 lines.append('')186 lines.append('')
187 if development:187 if '-dev.' in version:
188 lines += [f'[Development builds](/mirrors/zig/{version}/dev/)', '']
189 elif '-dev.' in version:
190 lines += [f'[All development builds](/mirrors/zig/{version.split("-")[0]}/dev/)', '']188 lines += [f'[All development builds](/mirrors/zig/{version.split("-")[0]}/dev/)', '']
191 if not artifacts:189 if not artifacts:
192 return '\n'.join(lines).encode()190 return '\n'.join(lines).encode()
...@@ -414,8 +412,11 @@ class Mirror:...@@ -414,8 +412,11 @@ class Mirror:
414 for url in re.findall(r'''(?:href=["']|\]\()([^"')\s]+)''', previous.decode())}412 for url in re.findall(r'''(?:href=["']|\]\()([^"')\s]+)''', previous.decode())}
415 linked = {name for name in present if PATTERN.fullmatch(name)}413 linked = {name for name in present if PATTERN.fullmatch(name)}
416 introduction = content.split(b'<div ', 1)[0]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:415 preserved = previous
418 return None416 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 if previous == content:420 if previous == content:
420 return None421 return None
421 return {'path': str(path.relative_to(self.root)), 'before': before,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,6 +271,7 @@ class MirrorTests(unittest.TestCase):
271 self.assertEqual(self.cache.root.stat().st_mtime_ns, stamp)271 self.assertEqual(self.cache.root.stat().st_mtime_ns, stamp)
272 self.assertFalse(list(self.cache.root.rglob('.download-*')))272 self.assertFalse(list(self.cache.root.rglob('.download-*')))
273 self.assertIn('Signature for '+name, (artifact.parent/'preadme.md').read_text())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 self.assertIn('this release only has [development builds]', (artifact.parent.parent.parent/'preadme.md').read_text())275 self.assertIn('this release only has [development builds]', (artifact.parent.parent.parent/'preadme.md').read_text())
275276
276 @unittest.skipUnless(ctypes.util.find_library('sodium'), 'libsodium required')277 @unittest.skipUnless(ctypes.util.find_library('sodium'), 'libsodium required')
...@@ -381,8 +382,8 @@ class MirrorTests(unittest.TestCase):...@@ -381,8 +382,8 @@ class MirrorTests(unittest.TestCase):
381 self.assertNotIn(f'[{labels[key]}]({url})', text)382 self.assertNotIn(f'[{labels[key]}]({url})', text)
382 else:383 else:
383 self.assertIn(f'- [{labels[key]}]({url})', text)384 self.assertIn(f'- [{labels[key]}]({url})', text)
384 self.assertLess(text.index(url), text.index('[Development builds]'))385 self.assertLess(text.index(url), text.index('<div '))
385 self.assertLess(text.index('[Development builds]'), text.index('<div '))386 self.assertNotIn('[Development builds]', text)
386 with patch.object(mirror, 'index', return_value={'0.19.0': {'notes': 'https://example.org/notes', 'docs': None, 'stdDocs': 'https://ziglang.org/bad)link'}}):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 text = mirror.version_readme('0.19.0', [artifact]).decode()388 text = mirror.version_readme('0.19.0', [artifact]).decode()
388 for label in labels.values():389 for label in labels.values():
...@@ -393,17 +394,26 @@ class MirrorTests(unittest.TestCase):...@@ -393,17 +394,26 @@ class MirrorTests(unittest.TestCase):
393 artifact = self.cache.path('zig-x86_64-linux-0.17.0.tar.xz')394 artifact = self.cache.path('zig-x86_64-linux-0.17.0.tar.xz')
394 artifact.parent.mkdir()395 artifact.parent.mkdir()
395 artifact.write_bytes(b'already verified archive')396 artifact.write_bytes(b'already verified archive')
397 (artifact.parent / 'dev').mkdir()
396 stamp = mirror.stable_time('0.17.0')398 stamp = mirror.stable_time('0.17.0')
397 for path in [artifact, artifact.parent, self.cache.root]:399 for path in [artifact, artifact.parent, self.cache.root]:
398 mirror.set_mtime(path, stamp)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 mirror.set_mtime(artifact.parent, stamp)405 mirror.set_mtime(artifact.parent, stamp)
401 readme = artifact.parent / 'preadme.md'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 original = {path: path.stat().st_mtime_ns for path in [artifact, artifact.parent, self.cache.root, readme]}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 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')):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 self.cache.refresh()414 self.cache.refresh()
415 self.assertNotIn('[Development builds]', readme.read_text())
416 self.assertEqual(readme.read_text(), custom)
407 self.assertIn('[Language Reference](' + release['docs'] + ')', readme.read_text())417 self.assertIn('[Language Reference](' + release['docs'] + ')', readme.read_text())
408 self.assertIsNone(self.cache.directory_readme(artifact.parent))418 self.assertIsNone(self.cache.directory_readme(artifact.parent))
409 metadata.assert_any_call(refresh=True)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,13 +46,14 @@ refresh bypasses it, as does a cache miss for an unindexed stable version's date
46Refresh also updates the current release/build navigation when archives are46Refresh also updates the current release/build navigation when archives are
47already cached, preserving artifact and folder dates.47already cached, preserving artifact and folder dates.
4848
49Base versions link to their development index; a base folder with only development49Released base versions show their artifacts without a development-build link; a
50builds says “this release only has development builds out.” Each development50base folder with only development builds says “this release only has development
51version links back to its index, whose heading leaves the native directory listing51builds out.” Each development version links back to its index, whose heading
52to show the builds. Complete existing relative-link tables are retained when52leaves the native directory listing to show the builds. Complete existing
53their introduction matches the published links and navigation; incomplete or53relative-link tables are retained when their introduction matches the published
54production-only links are replaced. The owner's root `preadme.md` and hidden54links and navigation, removing the old standalone development-build link from
55history remain untouched.55released pages; incomplete or production-only links are replaced. The owner's
56root `preadme.md` and hidden history remain untouched.
5657
57Existing verified archives need a one-time metadata reconciliation. It reads58Existing verified archives need a one-time metadata reconciliation. It reads
58signature comments and file metadata, not archive bodies, and preserves atime,59signature comments and file metadata, not archive bodies, and preserves atime,