(ctx context.Context, httpClient *http.Client, repo ghrepo.Interface)
| 563 | } |
| 564 | |
| 565 | func getTopics(ctx context.Context, httpClient *http.Client, repo ghrepo.Interface) ([]string, error) { |
| 566 | apiPath := fmt.Sprintf("repos/%s/%s/topics", repo.RepoOwner(), repo.RepoName()) |
| 567 | req, err := http.NewRequestWithContext(ctx, "GET", ghinstance.RESTPrefix(repo.RepoHost())+apiPath, nil) |
| 568 | if err != nil { |
| 569 | return nil, err |
| 570 | } |
| 571 | |
| 572 | // "mercy-preview" is still needed for some GitHub Enterprise versions |
| 573 | req.Header.Set("Accept", "application/vnd.github.mercy-preview+json") |
| 574 | res, err := httpClient.Do(req) |
| 575 | if err != nil { |
| 576 | return nil, err |
| 577 | } |
| 578 | defer res.Body.Close() |
| 579 | |
| 580 | if res.StatusCode != http.StatusOK { |
| 581 | return nil, api.HandleHTTPError(res) |
| 582 | } |
| 583 | |
| 584 | var responseData struct { |
| 585 | Names []string `json:"names"` |
| 586 | } |
| 587 | dec := json.NewDecoder(res.Body) |
| 588 | err = dec.Decode(&responseData) |
| 589 | return responseData.Names, err |
| 590 | } |
| 591 | |
| 592 | func setTopics(ctx context.Context, httpClient *http.Client, repo ghrepo.Interface, topics []string) error { |
| 593 | payload := struct { |
no test coverage detected