merge: preserve the latest Wabi research in the document database migration

This commit is contained in:
2026-10-30 16:45:16 +08:00
7 changed files with 145 additions and 35 deletions
+6 -4
View File
@@ -7,14 +7,15 @@ import re
import subprocess
ROOT = Path(__file__).resolve().parents[1]
BASELINE = 'cffca6942b1bc0005321e1685f38593fb0b853d5' # Integration snapshot of PRs 14, 15 and 16 before database migration.
BASELINE = 'cffca6942b1bc0005321e1685f38593fb0b853d5' # Integration snapshot before database migration.
RESEARCH_REVISION = '74af205b2959e1bb6a1fe9f567bc87069ac6d12c' # Final PR 14 update received during integration.
def export(ref):
commit = subprocess.check_output(['git', 'rev-parse', '--verify', ref + '^{commit}'], cwd=ROOT, text=True).strip()
def read(name):
return subprocess.check_output(['git', 'show', f'{commit}:{name}'], cwd=ROOT).decode()
def read(name, revision=commit):
return subprocess.check_output(['git', 'show', f'{revision}:{name}'], cwd=ROOT).decode()
catalog = json.loads(read('content/catalog.json'))
names = subprocess.check_output(['git', 'ls-tree', '-r', '--name-only', commit, '--', 'content/docs'], cwd=ROOT, text=True).splitlines()
@@ -23,7 +24,8 @@ def export(ref):
source = name.removeprefix('content/docs/').removesuffix('.md')
metadata = catalog['documents'][source]
collection = next(c for c in catalog['collections'] if not c['path'] or source.startswith(c['path'] + '/'))
content = read(name)
revision = RESEARCH_REVISION if commit == BASELINE and source.startswith("ai-company-research/") else commit
content = read(name, revision)
title = re.search(r'^# (.+)$', content, re.M)
documents.append(dict(slug=metadata['slug'], sourceSlug=source, category=metadata['category'],
title=title[1].strip() if title else source, content=content,