11package command
22
33import (
4+ "errors"
45 "fmt"
56 "net/url"
67 "sort"
@@ -12,7 +13,6 @@ import (
1213 "github.com/github/gh-cli/internal/ghrepo"
1314 "github.com/github/gh-cli/pkg/githubtemplate"
1415 "github.com/github/gh-cli/utils"
15- "github.com/pkg/errors"
1616 "github.com/spf13/cobra"
1717)
1818
@@ -25,7 +25,7 @@ func prCreate(cmd *cobra.Command, _ []string) error {
2525
2626 client , err := apiClientForContext (ctx )
2727 if err != nil {
28- return errors . Wrap ( err , "could not initialize API client" )
28+ return fmt . Errorf ( "could not initialize API client: %w" , err )
2929 }
3030
3131 baseRepoOverride , _ := cmd .Flags ().GetString ("repo" )
@@ -36,12 +36,12 @@ func prCreate(cmd *cobra.Command, _ []string) error {
3636
3737 baseRepo , err := repoContext .BaseRepo ()
3838 if err != nil {
39- return errors . Wrap ( err , "could not determine the base repository" )
39+ return fmt . Errorf ( "could not determine base repository: %w" , err )
4040 }
4141
4242 headBranch , err := ctx .Branch ()
4343 if err != nil {
44- return errors . Wrap ( err , "could not determine the current branch" )
44+ return fmt . Errorf ( "could not determine the current branch: %w" , err )
4545 }
4646
4747 baseBranch , err := cmd .Flags ().GetString ("base" )
@@ -86,7 +86,7 @@ func prCreate(cmd *cobra.Command, _ []string) error {
8686 if headRemote == nil {
8787 headRemote , err = repoContext .RemoteForRepo (headRepo )
8888 if err != nil {
89- return errors . Wrap ( err , "git remote not found for head repository" )
89+ return fmt . Errorf ( "git remote not found for head repository: %w" , err )
9090 }
9191 }
9292
@@ -111,7 +111,7 @@ func prCreate(cmd *cobra.Command, _ []string) error {
111111
112112 isWeb , err := cmd .Flags ().GetBool ("web" )
113113 if err != nil {
114- return errors . Wrap ( err , "could not parse web" )
114+ return fmt . Errorf ( "could not parse web: %q" , err )
115115 }
116116 if isWeb {
117117 openURL := fmt .Sprintf (`https://github.com/%s/pull/%s` , ghrepo .FullName (headRepo ), headBranch )
@@ -130,11 +130,11 @@ func prCreate(cmd *cobra.Command, _ []string) error {
130130
131131 title , err := cmd .Flags ().GetString ("title" )
132132 if err != nil {
133- return errors . Wrap ( err , "could not parse title" )
133+ return fmt . Errorf ( "could not parse title: %w" , err )
134134 }
135135 body , err := cmd .Flags ().GetString ("body" )
136136 if err != nil {
137- return errors . Wrap ( err , "could not parse body" )
137+ return fmt . Errorf ( "could not parse body: %w" , err )
138138 }
139139
140140 action := SubmitAction
@@ -150,7 +150,7 @@ func prCreate(cmd *cobra.Command, _ []string) error {
150150
151151 tb , err := titleBodySurvey (cmd , title , body , templateFiles )
152152 if err != nil {
153- return errors . Wrap ( err , "could not collect title and/or body" )
153+ return fmt . Errorf ( "could not collect title and/or body: %w" , err )
154154 }
155155
156156 action = tb .Action
@@ -170,7 +170,7 @@ func prCreate(cmd *cobra.Command, _ []string) error {
170170
171171 isDraft , err := cmd .Flags ().GetBool ("draft" )
172172 if err != nil {
173- return errors . Wrap ( err , "could not parse draft" )
173+ return fmt . Errorf ( "could not parse draft: %w" , err )
174174 }
175175
176176 if action == SubmitAction {
@@ -184,7 +184,7 @@ func prCreate(cmd *cobra.Command, _ []string) error {
184184
185185 pr , err := api .CreatePullRequest (client , baseRepo , params )
186186 if err != nil {
187- return errors . Wrap ( err , "failed to create pull request" )
187+ return fmt . Errorf ( "failed to create pull request: %w" , err )
188188 }
189189
190190 fmt .Fprintln (cmd .OutOrStdout (), pr .URL )
0 commit comments