| 80 | } |
| 81 | |
| 82 | func 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 | |
| 115 | func pinIssue(httpClient *http.Client, repo ghrepo.Interface, issue *api.Issue) error { |
| 116 | var mutation struct { |