From 613060eba1d28c49e8348efdc67e0ec235c57633 Mon Sep 17 00:00:00 2001 From: bingshuo <565183519@qq.com> Date: Sun, 31 May 2026 13:35:20 +0800 Subject: [PATCH] =?UTF-8?q?D118=20step-2=20=C2=B7=20=E5=85=89=E6=B9=96?= =?UTF-8?q?=E5=8E=9F=E7=94=9F=E6=95=B0=E6=8D=AE=E5=BA=93=20=C2=B7=20Git?= =?UTF-8?q?=E6=A0=B8=E5=BF=83=E5=88=9D=E5=A7=8B=E5=8C=96=20HLDP=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- native-repo/modules/step-2-git-init.js | 56 ++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 native-repo/modules/step-2-git-init.js diff --git a/native-repo/modules/step-2-git-init.js b/native-repo/modules/step-2-git-init.js new file mode 100644 index 0000000..0376f71 --- /dev/null +++ b/native-repo/modules/step-2-git-init.js @@ -0,0 +1,56 @@ +/** + * ═══════════════════════════════════════ + * 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 };