fix: proper check when verifying a merge

This commit is contained in:
Bjarke Sporring
2026-01-21 11:39:30 +01:00
parent 39d8ace75c
commit c69b463f84
2 changed files with 21 additions and 16 deletions

View File

@@ -14,6 +14,7 @@
. "$PSScriptRoot\..\..\util.ps1"
$script:allChecksPassed = $true
$challengeRoot = "$PSScriptRoot\challenge"
Write-Host $PSScriptRoot
@@ -21,15 +22,13 @@ Write-Host $PSScriptRoot
# Check challenge directory exists
# ============================================================================
if (-not (Test-Path "challenge")) {
if (-not (Test-Path $challengeRoot)) {
Write-Error "Challenge directory not found." -ForegroundColor Red
Write-Host "Run .\setup.ps1 first to create the challenge environment." -ForegroundColor Yellow
exit 1
}
Push-Location "challenge"
if (-not (Test-Path ".git")) {
if (-not (Test-Path "$challengeRoot\.git")) {
Write-Error "Not a git repository." -ForegroundColor Red
Write-Host "Run ..\setup.ps1 first to create the challenge environment." -ForegroundColor Yellow
exit 1
@@ -58,7 +57,7 @@ if ($currentBranch -eq $mainBranch) {
# ============================================================================
# Check that merge is not in progress
# ============================================================================
if (Test-Path ".git/MERGE_HEAD") {
if (Test-Path "$challengeRoot/.git/MERGE_HEAD") {
Write-Fail "Merge is still in progress (conflicts not resolved)"
Write-Hint "Resolve conflicts in config.json, then: git add config.json && git commit"
exit 1
@@ -69,7 +68,7 @@ if (Test-Path ".git/MERGE_HEAD") {
# ============================================================================
# Check if config.json exists
# ============================================================================
if (-not (Test-Path "config.json")) {
if (-not (Test-Path "$challengeRoot\config.json")) {
Write-Fail "File 'config.json' not found"
Write-Hint "The config.json file should exist"
exit 1
@@ -122,8 +121,14 @@ if ($config.app.debug -eq $true) {
# ============================================================================
# Verify both branches were merged
# ============================================================================
$addTimeoutMerged = git log --oneline --grep="add-timeout" 2>$null | Select-String "Merge"
$addDebugMerged = git log --oneline --grep="add-debug" 2>$null | Select-String "Merge"
git merge-base --is-ancestor add-timeout main
$addTimeoutMerged = $LASTEXITCODE -eq 0
git merge-base --is-ancestor add-debug main
$addDebugMerged = $LASTEXITCODE -eq 0
Write-Host Timeout merged? $addDebugMerged
Write-Host Debug merged? $addDebugMerged
if ($addTimeoutMerged) {
Write-Pass "add-timeout branch has been merged"