From 48784fa4d8da557122d4be16609a1e5f972beb5e Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 3 Oct 2026 13:44:19 +0200 Subject: [PATCH] Unity build: the no-.git guard asks git for the checkout top, so an empty .git is refused and a worktree passes Finding asura:finding:cut-3-gate.s3.git-guard-existence-only. Co-Authored-By: Claude Opus 5.5 --- scripts/build-unity-package.ps1 | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/build-unity-package.ps1 b/scripts/build-unity-package.ps1 index 473b5d39..621a8034 100644 --- a/scripts/build-unity-package.ps1 +++ b/scripts/build-unity-package.ps1 @@ -10,10 +10,18 @@ $ErrorActionPreference = "Stop" $repoRoot = Split-Path -Parent $PSScriptRoot # The CultMath byte gate below needs a git checkout: ContinuousIntegrationBuild maps the repo root to /_/ -# through the SDK's git source root, so in a tree without .git (git archive, a source zip) the DLL names -# the absolute obj path and its bytes change with the directory. -if (-not (Test-Path -LiteralPath (Join-Path $repoRoot ".git"))) { - throw "$repoRoot has no .git, so CultMath.dll would carry this directory's path and fail the CultMath byte gate. Build from a git clone, not an archive or source zip." +# through the SDK's git source root, so in a tree that is not the top of a git checkout (git archive, a +# source zip, an empty .git) the DLL names the absolute obj path and its bytes change with the directory. +# Git itself answers, so a worktree, where .git is a file, passes. +$gitErrorAction = $ErrorActionPreference +$ErrorActionPreference = "Continue" +$gitTop = & git -C $repoRoot rev-parse --show-toplevel 2>$null +$gitExit = $LASTEXITCODE +$ErrorActionPreference = $gitErrorAction +$isGitTop = $gitExit -eq 0 -and $gitTop -and + ([System.IO.Path]::GetFullPath("$gitTop").TrimEnd('\', '/') -eq [System.IO.Path]::GetFullPath($repoRoot).TrimEnd('\', '/')) +if (-not $isGitTop) { + throw "$repoRoot is not the top of a git checkout (git rev-parse --show-toplevel: '$gitTop', exit $gitExit), so CultMath.dll would carry this directory's path and fail the CultMath byte gate. Build from a git clone or worktree, not an archive or source zip." } $templateRoot = Join-Path $repoRoot "unity\org.gamecult.cultlib" # Every managed publish the package is assembled from, in the order $publishedByName fills (last wins).