22package cmd
33
44import (
5+ "errors"
56 "fmt"
67 "os"
78 "regexp"
@@ -63,10 +64,10 @@ func runSubmit(cmd *cobra.Command, args []string) error {
6364
6465 // Validate flag combinations
6566 if submitPushOnlyFlag && submitUpdateOnlyFlag {
66- return fmt . Errorf ("--push-only and --update-only cannot be used together: --push-only skips all PR operations" )
67+ return errors . New ("--push-only and --update-only cannot be used together: --push-only skips all PR operations" )
6768 }
6869 if submitPushOnlyFlag && submitWebFlag {
69- return fmt . Errorf ("--push-only and --web cannot be used together: --push-only skips all PR operations" )
70+ return errors . New ("--push-only and --web cannot be used together: --push-only skips all PR operations" )
7071 }
7172 if submitFromFlag != "" && submitCurrentOnlyFlag {
7273 return fmt .Errorf ("--from and --current-only cannot be used together" )
@@ -86,7 +87,7 @@ func runSubmit(cmd *cobra.Command, args []string) error {
8687
8788 // Check if operation already in progress
8889 if state .Exists (g .GetGitDir ()) {
89- return fmt . Errorf ("operation already in progress; use 'gh stack continue' or 'gh stack abort'" )
90+ return errors . New ("operation already in progress; use 'gh stack continue' or 'gh stack abort'" )
9091 }
9192
9293 currentBranch , err := g .CurrentBranch ()
@@ -174,7 +175,7 @@ func runSubmit(cmd *cobra.Command, args []string) error {
174175 fmt .Println (s .Bold ("=== Phase 1: Restack ===" ))
175176 if cascadeErr := doCascadeWithState (g , cfg , branches , submitDryRunFlag , state .OperationSubmit , submitUpdateOnlyFlag , submitWebFlag , submitPushOnlyFlag , branchNames , stashRef , s ); cascadeErr != nil {
176177 // Stash is saved in state for conflicts; restore on other errors
177- if cascadeErr != ErrConflict && stashRef != "" {
178+ if ! errors . Is ( cascadeErr , ErrConflict ) && stashRef != "" {
178179 fmt .Println ("Restoring auto-stashed changes..." )
179180 if popErr := g .StashPop (stashRef ); popErr != nil {
180181 fmt .Printf ("%s could not restore stashed changes (commit %s): %v\n " , s .WarningIcon (), git .AbbrevSHA (stashRef ), popErr )
@@ -266,7 +267,8 @@ func doSubmitPRs(g *git.Git, cfg *config.Config, root *tree.Node, branches []*tr
266267
267268 existingPR , _ := cfg .GetPR (b .Name ) //nolint:errcheck // 0 is fine
268269
269- if existingPR > 0 {
270+ switch {
271+ case existingPR > 0 :
270272 // Update existing PR
271273 if dryRun {
272274 fmt .Printf ("%s Would update PR #%d base to %s\n " , s .Muted ("dry-run:" ), existingPR , s .Branch (parent ))
@@ -289,27 +291,28 @@ func doSubmitPRs(g *git.Git, cfg *config.Config, root *tree.Node, branches []*tr
289291 // If PR is a draft and now targets trunk, offer to publish
290292 maybeMarkPRReady (ghClient , existingPR , b .Name , parent , trunk , s )
291293 }
292- } else if ! updateOnly {
294+ case ! updateOnly :
293295 // Create new PR
294296 if dryRun {
295297 fmt .Printf ("%s Would create PR for %s (base: %s)\n " , s .Muted ("dry-run:" ), s .Branch (b .Name ), s .Branch (parent ))
296298 } else {
297299 prNum , adopted , err := createPRForBranch (g , ghClient , cfg , root , b .Name , parent , trunk , remoteBranches , s )
298- if err != nil {
300+ switch {
301+ case err != nil :
299302 fmt .Printf ("%s failed to create PR for %s: %v\n " , s .WarningIcon (), s .Branch (b .Name ), err )
300- } else if adopted {
303+ case adopted :
301304 fmt .Printf ("%s Adopted PR #%d for %s (%s)\n " , s .SuccessIcon (), prNum , s .Branch (b .Name ), ghClient .PRURL (prNum ))
302305 if openWeb {
303306 prURLs = append (prURLs , ghClient .PRURL (prNum ))
304307 }
305- } else {
308+ default :
306309 fmt .Printf ("%s Created PR #%d for %s (%s)\n " , s .SuccessIcon (), prNum , s .Branch (b .Name ), ghClient .PRURL (prNum ))
307310 if openWeb {
308311 prURLs = append (prURLs , ghClient .PRURL (prNum ))
309312 }
310313 }
311314 }
312- } else {
315+ default :
313316 fmt .Printf ("Skipping %s %s\n " , s .Branch (b .Name ), s .Muted ("(no existing PR, --update-only)" ))
314317 }
315318 }
@@ -447,7 +450,7 @@ func promptForPRDetails(branch, defaultTitle, defaultBody string, s *style.Style
447450 }
448451 title = strings .TrimSpace (title )
449452 if title == "" {
450- return "" , "" , fmt . Errorf ("PR title cannot be empty" )
453+ return "" , "" , errors . New ("PR title cannot be empty" )
451454 }
452455
453456 // Show the generated body and ask if user wants to edit
0 commit comments