MCPcopy
hub / github.com/cli/cli / unpinRun

Function unpinRun

pkg/cmd/issue/unpin/unpin.go:83–114  ·  view source on GitHub ↗
(opts *UnpinOptions)

Source from the content-addressed store, hash-verified

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

Callers 2

NewCmdUnpinFunction · 0.85
TestUnpinRunFunction · 0.85

Calls 7

FindIssueOrPRFunction · 0.92
FullNameFunction · 0.92
unpinIssueFunction · 0.85
ColorSchemeMethod · 0.80
YellowMethod · 0.80
SuccessIconWithColorMethod · 0.80
BaseRepoMethod · 0.65

Tested by 1

TestUnpinRunFunction · 0.68