-
Notifications
You must be signed in to change notification settings - Fork 7.4k
fix(scripts): Show git checkout error output on branch creation failure #2082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -293,8 +293,9 @@ $specFile = Join-Path $featureDir 'spec.md' | |
| if (-not $DryRun) { | ||
| if ($hasGit) { | ||
| $branchCreated = $false | ||
| $checkoutStderr = '' | ||
| try { | ||
| git checkout -q -b $branchName 2>$null | Out-Null | ||
| $checkoutStderr = git checkout -q -b $branchName 2>&1 | Out-String | ||
| if ($LASTEXITCODE -eq 0) { | ||
|
Comment on lines
+296
to
299
|
||
| $branchCreated = $true | ||
| } | ||
|
|
@@ -308,9 +309,12 @@ if (-not $DryRun) { | |
| if ($existingBranch) { | ||
| if ($AllowExistingBranch) { | ||
| # Switch to the existing branch instead of failing | ||
| git checkout -q $branchName 2>$null | Out-Null | ||
| $checkoutStderr = git checkout -q $branchName 2>&1 | Out-String | ||
| if ($LASTEXITCODE -ne 0) { | ||
| Write-Error "Error: Branch '$branchName' exists but could not be checked out. Resolve any uncommitted changes or conflicts and try again." | ||
| if (-not [string]::IsNullOrWhiteSpace($checkoutStderr)) { | ||
| [Console]::Error.WriteLine($checkoutStderr.TrimEnd()) | ||
| } | ||
| exit 1 | ||
| } | ||
| } elseif ($Timestamp) { | ||
|
|
@@ -322,6 +326,9 @@ if (-not $DryRun) { | |
| } | ||
| } else { | ||
| Write-Error "Error: Failed to create git branch '$branchName'. Please check your git configuration and try again." | ||
| if (-not [string]::IsNullOrWhiteSpace($checkoutStderr)) { | ||
| [Console]::Error.WriteLine($checkoutStderr.TrimEnd()) | ||
| } | ||
| exit 1 | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.