guanghulab/native-repo/modules/step-2-git-init.js
Guanghu Domestic Migration d1e47f4565
Some checks are pending
自动更新代码和重启 / update-and-restart (push) Waiting to run
CI检查 + 自动部署 / check (push) Waiting to run
CI检查 + 自动部署 / deploy (push) Blocked by required conditions
重启聊天服务 / restart (push) Waiting to run
chore: import sanitized domestic snapshot for REPO-002
Source snapshot: ca48d3ddf926d79aa138306164169baf764bb829
2026-07-17 15:54:41 +08:00

57 lines
1.9 KiB
JavaScript

/**
* ═══════════════════════════════════════
* 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 };