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