| 57 | } |
| 58 | |
| 59 | func remoteTagExists(httpClient *http.Client, repo ghrepo.Interface, tagName string) (bool, error) { |
| 60 | gql := api.NewClientFromHTTP(httpClient) |
| 61 | qualifiedTagName := fmt.Sprintf("refs/tags/%s", tagName) |
| 62 | var query struct { |
| 63 | Repository struct { |
| 64 | Ref struct { |
| 65 | ID string |
| 66 | } `graphql:"ref(qualifiedName: $tagName)"` |
| 67 | } `graphql:"repository(owner: $owner, name: $name)"` |
| 68 | } |
| 69 | variables := map[string]interface{}{ |
| 70 | "owner": githubv4.String(repo.RepoOwner()), |
| 71 | "name": githubv4.String(repo.RepoName()), |
| 72 | "tagName": githubv4.String(qualifiedTagName), |
| 73 | } |
| 74 | err := gql.Query(repo.RepoHost(), "RepositoryFindRef", &query, variables) |
| 75 | return query.Repository.Ref.ID != "", err |
| 76 | } |