iter(g232): doctor 补 git 身份检查
This commit is contained in:
@@ -1625,6 +1625,9 @@ function cmdDoctor() {
|
||||
const hooksPath = spawnSync('git', ['config', 'core.hooksPath'], { cwd: ROOT }).stdout?.toString().trim(); // 显式 hooksPath 优先,默认取 .git/hooks
|
||||
const hookDir = hooksPath ? path.resolve(ROOT, hooksPath) : path.join(ROOT, '.git', 'hooks');
|
||||
checks.push({ name: 'commit-msg 钩子在位', pass: fs.existsSync(path.join(hookDir, 'commit-msg')) });
|
||||
const gitCfg = (k) => spawnSync('git', ['config', k], { cwd: ROOT }).stdout?.toString().trim() ?? '';
|
||||
const gitIdOk = !!gitCfg('user.name') && !!gitCfg('user.email');
|
||||
checks.push({ name: 'git 身份已配置(user.name / user.email)', pass: gitIdOk, detail: gitIdOk ? '' : '先执行 git config --global user.name/user.email,否则提交被拒' });
|
||||
const tryJson = (rel) => { // 存在且能 JSON.parse 才算过
|
||||
const p = path.join(ROOT, rel);
|
||||
if (!fs.existsSync(p)) return `文件不存在`;
|
||||
|
||||
Reference in New Issue
Block a user