File tree Expand file tree Collapse file tree
tests/OpenClaw.Tray.Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -138,6 +138,24 @@ function Ensure-GitVersionRepositoryTrust {
138138 Write-Success " Repository trusted for GitVersion"
139139}
140140
141+ function Ensure-GitVersionRepositoryHistory {
142+ $insideWorkTree = & git - C $repoRoot rev- parse - -is - inside- work- tree 2> $null
143+ if ($LASTEXITCODE -ne 0 -or $insideWorkTree -ne " true" ) {
144+ Write-Error " Git metadata not found. GitVersion requires a git clone with full history."
145+ Write-Info " Clone the repository with git, then rerun .\build.ps1."
146+ $script :issues += " Repository is missing git metadata required by GitVersion"
147+ return
148+ }
149+
150+ $isShallow = & git - C $repoRoot rev- parse - -is - shallow- repository 2> $null
151+ if ($LASTEXITCODE -eq 0 -and $isShallow -eq " true" ) {
152+ Write-Error " Repository is a shallow clone. GitVersion requires full git history."
153+ Write-Info " Run this once, then retry the build:"
154+ Write-Info " git fetch --unshallow --tags origin"
155+ $script :issues += " Repository is shallow; GitVersion requires full history"
156+ }
157+ }
158+
141159Write-Host @"
142160
143161 🦞 OpenClaw Windows Hub - Build Script
@@ -200,6 +218,7 @@ if (-not $git) {
200218 }
201219
202220 Ensure- GitVersionRepositoryTrust
221+ Ensure- GitVersionRepositoryHistory
203222}
204223
205224# Check Node.js + npm (WinUI build runs `npm ci` to restore @microsoft/mxc-sdk
Original file line number Diff line number Diff line change @@ -55,6 +55,18 @@ public void GitVersion_MainBranchPreservesAlphaReleaseTags()
5555 mainBranchMatch . Groups [ "body" ] . Value ) ;
5656 }
5757
58+ [ Fact ]
59+ public void BuildScript_PreflightsGitVersionRepositoryHistory ( )
60+ {
61+ var repoRoot = TestRepositoryPaths . GetRepositoryRoot ( ) ;
62+ var buildScript = File . ReadAllText ( Path . Combine ( repoRoot , "build.ps1" ) ) ;
63+
64+ Assert . Contains ( "Git metadata not found. GitVersion requires a git clone with full history." , buildScript ) ;
65+ Assert . Contains ( "rev-parse --is-shallow-repository" , buildScript ) ;
66+ Assert . Contains ( "GitVersion requires full git history" , buildScript ) ;
67+ Assert . Contains ( "git fetch --unshallow --tags origin" , buildScript ) ;
68+ }
69+
5870 [ Fact ]
5971 public void ActiveCodeAndTests_DoNotContainStaleReleaseVersion ( )
6072 {
You can’t perform that action at this time.
0 commit comments