Merge origin/main into align-wilm-main (align wilm with Cameron's latest)
Bring main's endpoint hardening, operator-report validation, launch-path policy, and theme-variable CSS into wilm. Channel model reconciled to this repo's shipping (stable=release tag, edge=main trunk) while keeping wilm's remote-BuildKit publish step and GHCR pull-based launcher.
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
GCM handles those.
|
||||
|
||||
.PARAMETER Channel
|
||||
'stable' (main) or 'edge' (dev-be). Defaults to 'stable'.
|
||||
'stable' (the newest release tag) or 'edge' (main, the trunk). Defaults to 'stable'.
|
||||
|
||||
.PARAMETER TargetDir
|
||||
Where to clone. Defaults to %USERPROFILE%\shopdb-dev, a separate working copy
|
||||
@@ -85,12 +85,28 @@ function Clear-InterruptedRun {
|
||||
}
|
||||
}
|
||||
|
||||
# A directory that exists but has no valid .git is a broken/partial clone;
|
||||
# remove it so the clone below can start fresh instead of failing.
|
||||
if ((Test-Path $Target) -and -not (Test-Path (Join-Path $Target '.git'))) {
|
||||
# A directory that exists but has no valid .git is a broken/partial clone -
|
||||
# USUALLY. It is also what -TargetDir pointed at somebody's Documents folder
|
||||
# looks like, and this ran Remove-Item -Recurse -Force on it without asking.
|
||||
# For a script distributed as "save it anywhere and run it", a mistyped
|
||||
# -TargetDir must not be able to delete a user's files.
|
||||
#
|
||||
# Only reclaim a directory this script can show it owns: empty, or carrying
|
||||
# the marker written after a successful clone. Anything else stops.
|
||||
if ((Test-Path $Target) -and -not (Test-Path (Join-Path $Target '.git'))) {
|
||||
$ours = Test-Path (Join-Path $Target $script:CloneMarker)
|
||||
$empty = -not (Get-ChildItem -LiteralPath $Target -Force |
|
||||
Select-Object -First 1)
|
||||
if ($ours -or $empty) {
|
||||
Write-Host "==> Removing incomplete clone at $Target" -ForegroundColor Cyan
|
||||
Remove-Item -Path $Target -Recurse -Force
|
||||
}
|
||||
else {
|
||||
throw ("$Target already exists, is not empty, and was not created " +
|
||||
"by this launcher. Refusing to delete it. Pass -TargetDir " +
|
||||
'pointing somewhere else, or remove it yourself if you are sure.')
|
||||
}
|
||||
}
|
||||
|
||||
# A clone created by an elevated (Administrator) run is owned by
|
||||
# BUILTIN\Administrators; a later non-elevated run then trips git's
|
||||
@@ -104,8 +120,18 @@ function Clear-InterruptedRun {
|
||||
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
|
||||
# Same rule as above: a .git directory proves this is a clone, but
|
||||
# not that it is OUR clone, and re-cloning discards whatever is in
|
||||
# it. Only reclaim one this launcher created.
|
||||
if (Test-Path (Join-Path $Target $script:CloneMarker)) {
|
||||
Write-Host "==> Removing clone with mismatched ownership at $Target (was it created from an elevated prompt?)" -ForegroundColor Cyan
|
||||
Remove-Item -Path $Target -Recurse -Force
|
||||
}
|
||||
else {
|
||||
throw ("The git clone at $Target has mismatched ownership and " +
|
||||
'was not created by this launcher, so it is not being ' +
|
||||
'deleted. Remove it yourself, or pass -TargetDir elsewhere.')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,7 +140,21 @@ function Clear-InterruptedRun {
|
||||
# stored GitHub credential for github.com, so clone/fetch authenticate against
|
||||
# the private repo without anything sensitive touching this script or disk.
|
||||
$repoUrl = 'https://github.com/ge-aero/shopdb-flask.git'
|
||||
$branch = if ($Channel -eq 'edge') { 'dev-be' } else { 'main' }
|
||||
# Written into a clone this launcher made, so a later run can tell its own
|
||||
# working directory apart from one that happens to sit at the same path.
|
||||
$script:CloneMarker = '.shopdb-launcher'
|
||||
# Channels follow how this repo ships: a release is a TAG, the trunk is main.
|
||||
# Upstream this read 'dev-be' for edge, which is that repo's trunk branch and
|
||||
# does not exist here - the launcher would have cloned a missing branch.
|
||||
$branch = 'main'
|
||||
if ($Channel -ne 'edge') {
|
||||
# Newest release tag, so 'stable' means a thing that was released rather
|
||||
# than whatever the trunk happens to be today.
|
||||
$tag = (git ls-remote --tags --refs --sort='-v:refname' $repoUrl 'v*' |
|
||||
Select-Object -First 1) -replace '.*refs/tags/', ''
|
||||
if ($tag) { $branch = $tag }
|
||||
else { Write-Warning "No v* tag found; falling back to main for 'stable'." }
|
||||
}
|
||||
$target = if ($TargetDir) { $TargetDir } else { Join-Path $env:USERPROFILE 'shopdb-dev' }
|
||||
|
||||
Write-Host "ShopDB dev launcher" -ForegroundColor White
|
||||
|
||||
Reference in New Issue
Block a user