MCPcopy
hub / github.com/cli/cli / pinRun

Function pinRun

pkg/cmd/issue/pin/pin.go:82–113  ·  view source on GitHub ↗
(opts *PinOptions)

Source from the content-addressed store, hash-verified

80}
81
82func pinRun(opts *PinOptions) error {
83 cs := opts.IO.ColorScheme()
84
85 httpClient, err := opts.HttpClient()
86 if err != nil {
87 return err
88 }
89
90 baseRepo, err := opts.BaseRepo()
91 if err != nil {
92 return err
93 }
94
95 issue, err := shared.FindIssueOrPR(httpClient, baseRepo, opts.IssueNumber, []string{"id", "number", "title", "isPinned"})
96 if err != nil {
97 return err
98 }
99
100 if issue.IsPinned {
101 fmt.Fprintf(opts.IO.ErrOut, "%s Issue %s#%d (%s) is already pinned\n", cs.Yellow("!"), ghrepo.FullName(baseRepo), issue.Number, issue.Title)
102 return nil
103 }
104
105 err = pinIssue(httpClient, baseRepo, issue)
106 if err != nil {
107 return err
108 }
109
110 fmt.Fprintf(opts.IO.ErrOut, "%s Pinned issue %s#%d (%s)\n", cs.SuccessIcon(), ghrepo.FullName(baseRepo), issue.Number, issue.Title)
111
112 return nil
113}
114
115func pinIssue(httpClient *http.Client, repo ghrepo.Interface, issue *api.Issue) error {
116 var mutation struct {

Callers 2

NewCmdPinFunction · 0.85
TestPinRunFunction · 0.85

Calls 7

FindIssueOrPRFunction · 0.92
FullNameFunction · 0.92
pinIssueFunction · 0.85
ColorSchemeMethod · 0.80
YellowMethod · 0.80
SuccessIconMethod · 0.80
BaseRepoMethod · 0.65

Tested by 1

TestPinRunFunction · 0.68