MCPcopy
hub / github.com/cli/cli / reopenRun

Function reopenRun

pkg/cmd/issue/reopen/reopen.go:69–116  ·  view source on GitHub ↗
(opts *ReopenOptions)

Source from the content-addressed store, hash-verified

67}
68
69func reopenRun(opts *ReopenOptions) error {
70 cs := opts.IO.ColorScheme()
71
72 httpClient, err := opts.HttpClient()
73 if err != nil {
74 return err
75 }
76
77 baseRepo, err := opts.BaseRepo()
78 if err != nil {
79 return err
80 }
81
82 issue, err := shared.FindIssueOrPR(httpClient, baseRepo, opts.IssueNumber, []string{"id", "number", "title", "state"})
83 if err != nil {
84 return err
85 }
86
87 if issue.State == "OPEN" {
88 fmt.Fprintf(opts.IO.ErrOut, "%s Issue %s#%d (%s) is already open\n", cs.Yellow("!"), ghrepo.FullName(baseRepo), issue.Number, issue.Title)
89 return nil
90 }
91
92 if opts.Comment != "" {
93 commentOpts := &prShared.CommentableOptions{
94 Body: opts.Comment,
95 HttpClient: opts.HttpClient,
96 InputType: prShared.InputTypeInline,
97 Quiet: true,
98 RetrieveCommentable: func() (prShared.Commentable, ghrepo.Interface, error) {
99 return issue, baseRepo, nil
100 },
101 }
102 err := prShared.CommentableRun(commentOpts)
103 if err != nil {
104 return err
105 }
106 }
107
108 err = apiReopen(httpClient, baseRepo, issue)
109 if err != nil {
110 return err
111 }
112
113 fmt.Fprintf(opts.IO.ErrOut, "%s Reopened issue %s#%d (%s)\n", cs.SuccessIconWithColor(cs.Green), ghrepo.FullName(baseRepo), issue.Number, issue.Title)
114
115 return nil
116}
117
118func apiReopen(httpClient *http.Client, repo ghrepo.Interface, issue *api.Issue) error {
119 if issue.IsPullRequest() {

Callers 1

NewCmdReopenFunction · 0.70

Calls 6

FullNameFunction · 0.92
apiReopenFunction · 0.85
ColorSchemeMethod · 0.80
YellowMethod · 0.80
SuccessIconWithColorMethod · 0.80
BaseRepoMethod · 0.65

Tested by

no test coverage detected