From 3cbba2df1446ae5074bfd44a911a0a8a517ba458 Mon Sep 17 00:00:00 2001 From: "benjamin.baker" Date: Wed, 2 Sep 2026 08:54:37 -0400 Subject: [PATCH] re-clone when git reports dubious ownership on the working copy a clone first created from an elevated prompt is owned by Administrators; a later normal-user run then fails every git op with 'dubious ownership' (exit 128), which the launcher misreported as an auth error. detect that case and remove the clone for a clean re-clone. --- scripts/Start-ShopDBDev.ps1 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/scripts/Start-ShopDBDev.ps1 b/scripts/Start-ShopDBDev.ps1 index ec6ff9f8..bd0e8a48 100644 --- a/scripts/Start-ShopDBDev.ps1 +++ b/scripts/Start-ShopDBDev.ps1 @@ -91,6 +91,23 @@ function Clear-InterruptedRun { Write-Host "==> Removing incomplete clone at $Target" -ForegroundColor Cyan Remove-Item -Path $Target -Recurse -Force } + + # A clone created by an elevated (Administrator) run is owned by + # BUILTIN\Administrators; a later non-elevated run then trips git's + # "detected dubious ownership" guard and every git op fails with exit 128. + # That stale clone is effectively unusable for this user, so detect the + # condition and remove it here for a clean re-clone rather than surfacing a + # misleading auth error later. + if (Test-Path (Join-Path $Target '.git')) { + $previous = $ErrorActionPreference + $ErrorActionPreference = 'Continue' + try { $probe = git -C $Target rev-parse --is-inside-work-tree 2>&1 } catch { $probe = "$_" } + finally { $ErrorActionPreference = $previous } + if ($probe -match 'dubious ownership') { + Write-Host "==> Removing clone with mismatched ownership at $Target (was it created from an elevated prompt?)" -ForegroundColor Cyan + Remove-Item -Path $Target -Recurse -Force + } + } } # Plain https URL. No token in the URL: Git Credential Manager injects the