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