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):
184184 lines.append(f'- [{label}]({url})')
185185 if lines[-1]:
186186 lines.append('')
187 if development:
188 lines += [f'[Development builds](/mirrors/zig/{version}/dev/)', '']
189 elif '-dev.' in version:
187 if '-dev.' in version:
190188 lines += [f'[All development builds](/mirrors/zig/{version.split("-")[0]}/dev/)', '']
191189 if not artifacts:
192190 return '\n'.join(lines).encode()
......@@ -414,8 +412,11 @@ class Mirror:
414412 for url in re.findall(r'''(?:href=["']|\]\()([^"')\s]+)''', previous.decode())}
415413 linked = {name for name in present if PATTERN.fullmatch(name)}
416414 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
419420 if previous == content:
420421 return None
421422 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):
271271 self.assertEqual(self.cache.root.stat().st_mtime_ns, stamp)
272272 self.assertFalse(list(self.cache.root.rglob('.download-*')))
273273 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())
274275 self.assertIn('this release only has [development builds]', (artifact.parent.parent.parent/'preadme.md').read_text())
275276
276277 @unittest.skipUnless(ctypes.util.find_library('sodium'), 'libsodium required')
......@@ -381,8 +382,8 @@ class MirrorTests(unittest.TestCase):
381382 self.assertNotIn(f'[{labels[key]}]({url})', text)
382383 else:
383384 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)
386387 with patch.object(mirror, 'index', return_value={'0.19.0': {'notes': 'https://example.org/notes', 'docs': None, 'stdDocs': 'https://ziglang.org/bad)link'}}):
387388 text = mirror.version_readme('0.19.0', [artifact]).decode()
388389 for label in labels.values():
......@@ -393,17 +394,26 @@ class MirrorTests(unittest.TestCase):
393394 artifact = self.cache.path('zig-x86_64-linux-0.17.0.tar.xz')
394395 artifact.parent.mkdir()
395396 artifact.write_bytes(b'already verified archive')
397 (artifact.parent / 'dev').mkdir()
396398 stamp = mirror.stable_time('0.17.0')
397399 for path in [artifact, artifact.parent, self.cache.root]:
398400 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)
400405 mirror.set_mtime(artifact.parent, stamp)
401406 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())
402412 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'}}
405413 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')):
406414 self.cache.refresh()
415 self.assertNotIn('[Development builds]', readme.read_text())
416 self.assertEqual(readme.read_text(), custom)
407417 self.assertIn('[Language Reference](' + release['docs'] + ')', readme.read_text())
408418 self.assertIsNone(self.cache.directory_readme(artifact.parent))
409419 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
4646Refresh also updates the current release/build navigation when archives are
4747already cached, preserving artifact and folder dates.
4848
49Base versions link to their development index; a base folder with only development
50builds says “this release only has development builds out.” Each development
51version links back to its index, whose heading leaves the native directory listing
52to show the builds. Complete existing relative-link tables are retained when
53their introduction matches the published links and navigation; incomplete or
54production-only links are replaced. The owner's root `preadme.md` and hidden
55history remain untouched.
49Released base versions show their artifacts without a development-build link; a
50base folder with only development builds says “this release only has development
51builds out.” Each development version links back to its index, whose heading
52leaves the native directory listing to show the builds. Complete existing
53relative-link tables are retained when their introduction matches the published
54links and navigation, removing the old standalone development-build link from
55released pages; incomplete or production-only links are replaced. The owner's
56root `preadme.md` and hidden history remain untouched.
5657
5758Existing verified archives need a one-time metadata reconciliation. It reads
5859signature comments and file metadata, not archive bodies, and preserves atime,