From 7756630d87464c5737fa97d514396b70d5fd6f6d Mon Sep 17 00:00:00 2001 From: Manfred Riem <15701806+mnriem@users.noreply.github.com> Date: Thu, 7 May 2026 11:57:08 -0500 Subject: [PATCH] fix: move branch validation after --paths-only exit check-prerequisites.sh and check-prerequisites.ps1 ran branch validation before the --paths-only early exit, causing --paths-only to fail on non-feature branches despite documentation stating 'no validation'. Move check_feature_branch / Test-FeatureBranch after the paths-only block so callers that only need path variables are not subject to branch-name checks. Fixes #2477 --- scripts/bash/check-prerequisites.sh | 6 ++++-- scripts/powershell/check-prerequisites.ps1 | 11 ++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/bash/check-prerequisites.sh b/scripts/bash/check-prerequisites.sh index 88a5559460..a5d534ce7f 100644 --- a/scripts/bash/check-prerequisites.sh +++ b/scripts/bash/check-prerequisites.sh @@ -78,11 +78,10 @@ done SCRIPT_DIR="$(CDPATH="" cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$SCRIPT_DIR/common.sh" -# Get feature paths and validate branch +# Get feature paths _paths_output=$(get_feature_paths) || { echo "ERROR: Failed to resolve feature paths" >&2; exit 1; } eval "$_paths_output" unset _paths_output -check_feature_branch "$CURRENT_BRANCH" "$HAS_GIT" || exit 1 # If paths-only mode, output paths and exit (support JSON + paths-only combined) if $PATHS_ONLY; then @@ -112,6 +111,9 @@ if $PATHS_ONLY; then exit 0 fi +# Validate branch name +check_feature_branch "$CURRENT_BRANCH" "$HAS_GIT" || exit 1 + # Validate required directories and files if [[ ! -d "$FEATURE_DIR" ]]; then echo "ERROR: Feature directory not found: $FEATURE_DIR" >&2 diff --git a/scripts/powershell/check-prerequisites.ps1 b/scripts/powershell/check-prerequisites.ps1 index 91667e9ef1..fdc7d50cf5 100644 --- a/scripts/powershell/check-prerequisites.ps1 +++ b/scripts/powershell/check-prerequisites.ps1 @@ -56,13 +56,9 @@ EXAMPLES: # Source common functions . "$PSScriptRoot/common.ps1" -# Get feature paths and validate branch +# Get feature paths $paths = Get-FeaturePathsEnv -if (-not (Test-FeatureBranch -Branch $paths.CURRENT_BRANCH -HasGit:$paths.HAS_GIT)) { - exit 1 -} - # If paths-only mode, output paths and exit (support combined -Json -PathsOnly) if ($PathsOnly) { if ($Json) { @@ -85,6 +81,11 @@ if ($PathsOnly) { exit 0 } +# Validate branch name +if (-not (Test-FeatureBranch -Branch $paths.CURRENT_BRANCH -HasGit:$paths.HAS_GIT)) { + exit 1 +} + # Validate required directories and files if (-not (Test-Path $paths.FEATURE_DIR -PathType Container)) { Write-Output "ERROR: Feature directory not found: $($paths.FEATURE_DIR)"