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