File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed
Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -327,13 +327,17 @@ SPEC_FILE="$FEATURE_DIR/spec.md"
327327
328328if [ " $DRY_RUN " != true ]; then
329329 if [ " $HAS_GIT " = true ]; then
330- if ! git checkout -b " $BRANCH_NAME " 2> /dev/null; then
330+ checkout_stderr=" "
331+ if ! { checkout_stderr=$( git checkout -b " $BRANCH_NAME " 2>&1 1>&3 ) ; } 3>&1 ; then
331332 # Check if branch already exists
332333 if git branch --list " $BRANCH_NAME " | grep -q . ; then
333334 if [ " $ALLOW_EXISTING " = true ]; then
334335 # Switch to the existing branch instead of failing
335- if ! git checkout " $BRANCH_NAME " 2> /dev/null ; then
336+ if ! { checkout_stderr= $( git checkout " $BRANCH_NAME " 2>&1 1>&3 ) ; } 3>&1 ; then
336337 >&2 echo " Error: Failed to switch to existing branch '$BRANCH_NAME '. Please resolve any local changes or conflicts and try again."
338+ if [ -n " $checkout_stderr " ]; then
339+ >&2 echo " $checkout_stderr "
340+ fi
337341 exit 1
338342 fi
339343 elif [ " $USE_TIMESTAMP " = true ]; then
@@ -345,6 +349,9 @@ if [ "$DRY_RUN" != true ]; then
345349 fi
346350 else
347351 >&2 echo " Error: Failed to create git branch '$BRANCH_NAME '. Please check your git configuration and try again."
352+ if [ -n " $checkout_stderr " ]; then
353+ >&2 echo " $checkout_stderr "
354+ fi
348355 exit 1
349356 fi
350357 fi
Original file line number Diff line number Diff line change @@ -293,8 +293,9 @@ $specFile = Join-Path $featureDir 'spec.md'
293293if (-not $DryRun ) {
294294 if ($hasGit ) {
295295 $branchCreated = $false
296+ $checkoutStderr = ' '
296297 try {
297- git checkout - q - b $branchName 2> $null | Out-Null
298+ $checkoutStderr = git checkout - q - b $branchName 2>&1 | Out-String
298299 if ($LASTEXITCODE -eq 0 ) {
299300 $branchCreated = $true
300301 }
@@ -308,9 +309,12 @@ if (-not $DryRun) {
308309 if ($existingBranch ) {
309310 if ($AllowExistingBranch ) {
310311 # Switch to the existing branch instead of failing
311- git checkout - q $branchName 2> $null | Out-Null
312+ $checkoutStderr = git checkout - q $branchName 2>&1 | Out-String
312313 if ($LASTEXITCODE -ne 0 ) {
313314 Write-Error " Error: Branch '$branchName ' exists but could not be checked out. Resolve any uncommitted changes or conflicts and try again."
315+ if (-not [string ]::IsNullOrWhiteSpace($checkoutStderr )) {
316+ [Console ]::Error.WriteLine($checkoutStderr.TrimEnd ())
317+ }
314318 exit 1
315319 }
316320 } elseif ($Timestamp ) {
@@ -322,6 +326,9 @@ if (-not $DryRun) {
322326 }
323327 } else {
324328 Write-Error " Error: Failed to create git branch '$branchName '. Please check your git configuration and try again."
329+ if (-not [string ]::IsNullOrWhiteSpace($checkoutStderr )) {
330+ [Console ]::Error.WriteLine($checkoutStderr.TrimEnd ())
331+ }
325332 exit 1
326333 }
327334 }
You can’t perform that action at this time.
0 commit comments