NewUploader returns the uploader for a command's --attach files, which upload against the issue's repository with the token for its host. It refuses a pull request like CheckIssue, from the one lookup that also returns the repository ID and permission an upload needs, so a caller makes no other look
(c client.ArtifactClient, repo ghrepo.Interface, issueNumber int, httpClient func() (*http.Client, error))
| 260 | // returns the repository ID and permission an upload needs, so a caller makes |
| 261 | // no other lookup. |
| 262 | func NewUploader(c client.ArtifactClient, repo ghrepo.Interface, issueNumber int, httpClient func() (*http.Client, error)) (*attachments.Uploader, error) { |
| 263 | target, err := CheckUploadTarget(c, repo, issueNumber) |
| 264 | if err != nil { |
| 265 | return nil, err |
| 266 | } |
| 267 | hc, err := httpClient() |
| 268 | if err != nil { |
| 269 | return nil, err |
| 270 | } |
| 271 | return attachments.NewUploader(hc, repo.RepoHost(), target.RepositoryID, target.ViewerPermission) |
| 272 | } |
| 273 | |
| 274 | func pullRequestError(repo ghrepo.Interface, number int) error { |
| 275 | return fmt.Errorf("%s#%d is a pull request; artifacts are only supported on issues", ghrepo.FullName(repo), number) |