sync: WIN10-I9-64G 2026-07-20

This commit is contained in:
Myfro9
2026-07-20 18:18:50 +08:00
parent 2ef32a9dcc
commit 96b014edb3
+16 -2
View File
@@ -69,13 +69,27 @@ if (-not $DryRun) {
Write-Host "=== [2/2] mirror: $CodexSkills ===" Write-Host "=== [2/2] mirror: $CodexSkills ==="
if (-not (Test-Path $CodexSkills)) { New-Item -ItemType Directory -Force $CodexSkills | Out-Null } if (-not (Test-Path $CodexSkills)) { New-Item -ItemType Directory -Force $CodexSkills | Out-Null }
if (-not (Test-Path (Join-Path $CodexSkills ".git"))) { # Bootstrap is needed when there's no repo yet, or a previous bootstrap died before
# origin/main ever arrived (init succeeded, fetch didn't).
$needBootstrap = -not (Test-Path (Join-Path $CodexSkills ".git"))
if (-not $needBootstrap) {
$r = Invoke-Git $CodexSkills @("rev-parse", "--verify", "--quiet", "refs/remotes/origin/$Branch")
if ($r.Code -ne 0) { $needBootstrap = $true }
}
if ($needBootstrap) {
Write-Host "bootstrapping mirror as a checkout of $RepoUrl" Write-Host "bootstrapping mirror as a checkout of $RepoUrl"
if ($DryRun) { Write-Host "(dry-run) would git init + fetch + align to origin/$Branch"; exit 0 } if ($DryRun) { Write-Host "(dry-run) would git init + fetch + align to origin/$Branch"; exit 0 }
Invoke-Git $CodexSkills @("init") | Out-Null Invoke-Git $CodexSkills @("init") | Out-Null
Invoke-Git $CodexSkills @("remote", "add", "origin", $RepoUrl) | Out-Null Invoke-Git $CodexSkills @("remote", "add", "origin", $RepoUrl) | Out-Null
$r = Invoke-Git $CodexSkills @("fetch", "origin", $Branch) $r = Invoke-Git $CodexSkills @("fetch", "origin", $Branch)
if ($r.Code -ne 0) { Write-Host $r.Out; Fail "fetch failed during bootstrap." } if ($r.Code -ne 0) {
# Flaky server on a full first fetch is common; the primary checkout already
# holds every object locally, so borrow them from disk instead.
Write-Host "server fetch failed, retrying from local primary checkout..."
$r = Invoke-Git $CodexSkills @("fetch", $ClaudeSkills, "+refs/heads/${Branch}:refs/remotes/origin/$Branch")
if ($r.Code -ne 0) { Write-Host $r.Out; Fail "fetch failed during bootstrap (server and local)." }
}
# Point index at origin/main without touching files, so status shows local-vs-repo drift. # Point index at origin/main without touching files, so status shows local-vs-repo drift.
Invoke-Git $CodexSkills @("reset", "origin/$Branch") | Out-Null Invoke-Git $CodexSkills @("reset", "origin/$Branch") | Out-Null
Invoke-Git $CodexSkills @("branch", "-f", $Branch, "origin/$Branch") | Out-Null Invoke-Git $CodexSkills @("branch", "-f", $Branch, "origin/$Branch") | Out-Null