@@ -28,7 +28,7 @@ func init() {
2828 prCmd .AddCommand (prCloseCmd )
2929 prCmd .AddCommand (prReopenCmd )
3030 prCmd .AddCommand (prMergeCmd )
31- prMergeCmd .Flags ().BoolP ("delete-branch" , "d" , true , "Delete the local branch after merge" )
31+ prMergeCmd .Flags ().BoolP ("delete-branch" , "d" , true , "Delete the local and remote branch after merge" )
3232 prMergeCmd .Flags ().BoolP ("merge" , "m" , false , "Merge the commits with the base branch" )
3333 prMergeCmd .Flags ().BoolP ("rebase" , "r" , false , "Rebase the commits onto the base branch" )
3434 prMergeCmd .Flags ().BoolP ("squash" , "s" , false , "Squash the commits into one commit and merge it into the base branch" )
@@ -560,7 +560,9 @@ func prMerge(cmd *cobra.Command, args []string) error {
560560 return err
561561 }
562562
563+ var branchToSwitchTo string
563564 if currentBranch == pr .HeadRefName {
565+ branchToSwitchTo = repo .DefaultBranchRef .Name
564566 err = git .CheckoutBranch (repo .DefaultBranchRef .Name )
565567 if err != nil {
566568 return err
@@ -569,10 +571,21 @@ func prMerge(cmd *cobra.Command, args []string) error {
569571
570572 err = git .DeleteLocalBranch (pr .HeadRefName )
571573 if err != nil {
572- fmt .Fprintf ( colorableErr ( cmd ), "%s Could not deleted local branch %s: %s \n " , utils . Red ( "!" ) , utils .Cyan (pr .HeadRefName ), err )
574+ fmt .Errorf ( "failed to delete local branch %s: %w" , utils .Cyan (pr .HeadRefName ), err )
573575 return err
574576 }
575- fmt .Fprintf (colorableOut (cmd ), "%s Deleted local branch %s\n " , utils .Red ("✔" ), utils .Cyan (pr .HeadRefName ))
577+
578+ err = git .DeleteRemoteBranch (pr .HeadRefName )
579+ if err != nil {
580+ fmt .Errorf ("failed to delete remote branch %s: %w" , utils .Cyan (pr .HeadRefName ), err )
581+ return err
582+ }
583+
584+ branchSwitchString := ""
585+ if branchToSwitchTo != "" {
586+ branchSwitchString = fmt .Sprintf ("and switched to branch %s" , utils .Cyan (branchToSwitchTo ))
587+ }
588+ fmt .Fprintf (colorableOut (cmd ), "%s Deleted branch %s %s\n " , utils .Red ("✔" ), utils .Cyan (pr .HeadRefName ), branchSwitchString )
576589 }
577590
578591 return nil
@@ -591,7 +604,7 @@ func prInteractiveMerge() (api.PullRequestMergeMethod, bool, error) {
591604 deleteBranchQuestion := & survey.Question {
592605 Name : "deleteBranch" ,
593606 Prompt : & survey.Confirm {
594- Message : "Delete the branch locally?" ,
607+ Message : "Delete the branch locally and on GitHub ?" ,
595608 Default : true ,
596609 },
597610 }
0 commit comments