FetchRepository returns the repository's ID and visibility.
(client *api.Client, host, owner, repo string)
| 214 | |
| 215 | // FetchRepository returns the repository's ID and visibility. |
| 216 | func FetchRepository(client *api.Client, host, owner, repo string) (*Repository, error) { |
| 217 | apiPath, err := safeurl.JoinPath("repos", owner, repo) |
| 218 | if err != nil { |
| 219 | return nil, err |
| 220 | } |
| 221 | var resp struct { |
| 222 | ID int64 `json:"id"` |
| 223 | Visibility string `json:"visibility"` |
| 224 | } |
| 225 | if err := client.REST(host, "GET", apiPath.String(), nil, &resp); err != nil { |
| 226 | return nil, err |
| 227 | } |
| 228 | if resp.ID == 0 { |
| 229 | return nil, fmt.Errorf("could not determine the ID of repository %s/%s", owner, repo) |
| 230 | } |
| 231 | vis, _ := parseRepoVisibility(resp.Visibility) |
| 232 | return &Repository{ID: resp.ID, Visibility: vis}, nil |
| 233 | } |
| 234 | |
| 235 | // ResolveRef determines the git ref to use for a given owner/repo. |
| 236 | // Priority: explicit version > latest release tag > default branch. |
no test coverage detected