Skip to content

Commit dc15020

Browse files
sheehanmunimclaude
andauthored
fix(fleet): restore the origin/main tracking ref on drifted Windows clones (#6)
A single-branch clone made against the old repo keeps a refspec that no longer writes refs/remotes/origin/main, so repointing the URL was not enough: the fetch only moved FETCH_HEAD and rev-parse still failed. The refresh now restates the refspec, and falls back to FETCH_HEAD rather than building whatever commit the machine sat on. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent b79c8ed commit dc15020

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

‎scripts/personal-refresh-win.ps1‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,24 @@ if ($LASTEXITCODE -ne 0) {
5050
git remote set-url origin $productRepoUrl
5151
}
5252

53+
# A single-branch clone from the old repo carries a refspec that no longer
54+
# writes refs/remotes/origin/main, so a bare `git fetch origin main` only
55+
# updates FETCH_HEAD and origin/main stays missing. Restate the refspec so the
56+
# tracking ref exists on every machine, however its clone was made.
57+
git config remote.origin.fetch "+refs/heads/main:refs/remotes/origin/main"
5358
git fetch origin main
5459
if ($LASTEXITCODE -ne 0) {
5560
Log "fetch from origin failed - refusing to build a stale checkout"
5661
exit 1
5762
}
5863
$new = (git rev-parse origin/main 2>$null)
5964
if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($new)) {
60-
Log "origin/main did not resolve - refusing to build a stale checkout"
65+
# Fall back to what the fetch just brought down rather than building
66+
# whatever this machine was sitting on.
67+
$new = (git rev-parse FETCH_HEAD 2>$null)
68+
}
69+
if ([string]::IsNullOrWhiteSpace($new)) {
70+
Log "could not resolve the product branch - refusing to build a stale checkout"
6171
exit 1
6272
}
6373
$new = $new.Trim()
@@ -77,8 +87,8 @@ if (($new -eq $old) -and ($force -ne "1")) {
7787
Log "no changes but staged installer missing - rebuilding"
7888
}
7989

80-
git checkout -B main origin/main
81-
git reset --hard origin/main
90+
git checkout -B main $new
91+
git reset --hard $new
8292

8393
# Bake Connect public client config into desktop artifacts (gitignored .env).
8494
# Without this, hasCloudPublicConfig() is false and Connect UI is omitted.

0 commit comments

Comments
 (0)