$ErrorActionPreference='Stop' $launcher=Get-Content (Join-Path $PSScriptRoot '../deploy-server.bat') $line=@($launcher | Where-Object { $_ -like 'powershell *' -and $_ -like '*$lines=@(& git*' }) if ($line.Count -ne 1) { throw 'Origin verification command missing' } $command=$line[0].Substring($line[0].IndexOf('-Command "')+10).TrimEnd('"') $env:DMS_REPOSITORY='https://gitea.hmac.kr/is-div/design-model-box-sample_2.git' $env:DMS_DEPLOY_SOURCE='C:\folder with spaces\deploy-source' $cases=@( @{url=$env:DMS_REPOSITORY;code=0;expected=0}, @{url=($env:DMS_REPOSITORY+"`r`n");code=0;expected=0}, @{url='https://example.invalid/other.git';code=0;expected=4}, @{url='';code=128;expected=2} ) foreach ($case in $cases) { $env:TEST_ORIGIN=$case.url $env:TEST_GIT_CODE=[string]$case.code $mock='function git { $global:LASTEXITCODE=[int]$env:TEST_GIT_CODE; if ($env:TEST_ORIGIN) { $env:TEST_ORIGIN } }; ' & (Join-Path $PSHOME 'pwsh') -NoProfile -Command ($mock+$command) if ($LASTEXITCODE -ne $case.expected) { throw "Unexpected exit: $LASTEXITCODE" } } Write-Host 'PASS: exact origin, line endings, different repository, Git error'