/** * ═══════════════════════════════════════ * HLDP-ZY://native-repo/module/step-2 * 光湖原生数据库 · 第2步 · Git核心初始化 * ═══════════════════════════════════════ * * @chain: D118 · 2026-05-31 * @module: git-core-init * @step: 第2步 / 共8步 * @deploy: BS-SG-002 · 新加坡面孔 * @sovereign: TCS-0002∞ · 冰朔 * @guardian: ICE-GL-ZY001 · 铸渊 * * @trigger: * 光湖需要自己的原生数据库。不用 Gitea/Forgejo。 * 依赖文件: isomorphic-git 已在 BS-SG-002 上安装 * * @intent: * bare git 仓库初始化。参考 isomorphic-git 的 git.init() * bare=true → 无工作目录,纯 .git 结构 * defaultBranch='main' * 路径: /data/guanghulab/native-repo/.git * * @lock: * ⊢ 仓库路径: /data/guanghulab/native-repo * ⊢ 初始化成功: HEAD → refs/heads/main * ⊢ objects/info/refs/hooks 已经创建 * ⊢ 下一步需要第一个 HLDP commit 才能激活仓库 * * @why: * bare 仓库不需要工作目录。铸渊不需要 checkout—— * 只需要 Blob/Tree/Commit 三种 Git 对象。 * isomorphic-git 提供纯 JS 接口,不需要 CLI。 * * ═══════════════════════════════════════ */ const git = require('isomorphic-git'); const fs = require('fs'); const path = require('path'); const NATIVE_DIR = path.join('/data/guanghulab/native-repo'); const GIT_DIR = path.join(NATIVE_DIR, '.git'); async function initNativeRepo() { await git.init({ fs, dir: GIT_DIR, bare: true, defaultBranch: 'main', }); console.log('HLDP-DB-INIT:OK'); return { dir: GIT_DIR, branch: 'main', status: 'bare' }; } module.exports = { initNativeRepo, NATIVE_DIR, GIT_DIR };