fix(v3.2.0): auto-detect and fix stale git remote in .claude/
When .claude/ was previously cloned from bookworm-portable-config (deleted), re-running the installer would git pull against the wrong remote. Now auto-detects stale remote and switches to bookworm-smart-assistant, then fetches + resets to get the correct content (including skills/). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
57ca443386
commit
1f90b933c2
Binary file not shown.
@ -1613,9 +1613,22 @@ if (Test-Path (Join-Path $ClaudeDir ".git")) {
|
||||
# 设置 git 身份 (auto-resolve commit 需要)
|
||||
& git -C $ClaudeDir config user.email "bookworm@auto.local" 2>$null
|
||||
& git -C $ClaudeDir config user.name "Bookworm" 2>$null
|
||||
# v3.2.0: 校验 remote URL, 旧仓库自动切换到新仓库
|
||||
try {
|
||||
$currentRemote = (& git -C $ClaudeDir remote get-url origin 2>$null) -replace '\.git$', ''
|
||||
$expectedBase = ($GitUrl -replace '\.git$', '')
|
||||
if ($currentRemote -and $currentRemote -notmatch 'bookworm-smart-assistant') {
|
||||
Log-Warn "配置仓库 remote 指向旧源: $currentRemote, 切换到 $GitUrl"
|
||||
& git -C $ClaudeDir remote set-url origin $GitUrl 2>$null
|
||||
Log-OK "remote 已切换到 bookworm-smart-assistant"
|
||||
}
|
||||
} catch {}
|
||||
try {
|
||||
# 强制清除冲突状态 (运行时文件不重要, Phase 5 会重新渲染)
|
||||
& git -C $ClaudeDir reset --hard HEAD 2>&1 | Out-Null
|
||||
# 如果 remote 已切换, 需要 fetch 新仓库再 reset
|
||||
& git -C $ClaudeDir fetch origin 2>&1 | Out-Null
|
||||
& git -C $ClaudeDir reset --hard origin/main 2>&1 | Out-Null
|
||||
$r = Run-CmdWithUI "git" @("-C", $ClaudeDir, "pull", "--rebase", "--autostash") "同步配置仓库" 120000
|
||||
if ($r.OK) {
|
||||
Log-OK "配置仓库已更新"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user