fix: _ensure_project_repo 在 git init 之后才配置仓库级 user(否则 git config 报 not a git repository 导致初始 commit 失败)

This commit is contained in:
ymq 2026-08-20 00:45:32 +08:00
parent c319cb74df
commit 7f05a3b467

View File

@ -742,10 +742,11 @@ async def _ensure_project_repo(workspace_dir):
async with _git_lock(repo_dir):
if os.path.isdir(os.path.join(repo_dir, '.git')):
return {'rc': 0, 'message': '项目过程仓库已存在'}
await _git_setup(repo_dir)
r = await _run_shell('git init', repo_dir, 10)
if r['rc'] != 0:
return {'rc': r['rc'], 'message': f"git init 失败: {r['stderr'][:200]}"}
# init 之后才能配置仓库级 user否则 git config 报 not a git repository
await _git_setup(repo_dir)
readme = os.path.join(repo_dir, 'README.md')
if not os.path.isfile(readme):
try: