| 49 | } |
| 50 | |
| 51 | func ListLinkedBranches(client *Client, repo ghrepo.Interface, issueNumber int) ([]LinkedBranch, error) { |
| 52 | var query struct { |
| 53 | Repository struct { |
| 54 | Issue struct { |
| 55 | LinkedBranches struct { |
| 56 | Nodes []struct { |
| 57 | Ref struct { |
| 58 | Name string |
| 59 | Repository struct { |
| 60 | Url string |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | } `graphql:"linkedBranches(first: 30)"` |
| 65 | } `graphql:"issue(number: $number)"` |
| 66 | } `graphql:"repository(owner: $owner, name: $name)"` |
| 67 | } |
| 68 | |
| 69 | variables := map[string]interface{}{ |
| 70 | "number": githubv4.Int(issueNumber), |
| 71 | "owner": githubv4.String(repo.RepoOwner()), |
| 72 | "name": githubv4.String(repo.RepoName()), |
| 73 | } |
| 74 | |
| 75 | if err := client.Query(repo.RepoHost(), "ListLinkedBranches", &query, variables); err != nil { |
| 76 | return []LinkedBranch{}, err |
| 77 | } |
| 78 | |
| 79 | var branchNames []LinkedBranch |
| 80 | |
| 81 | for _, node := range query.Repository.Issue.LinkedBranches.Nodes { |
| 82 | branch := LinkedBranch{ |
| 83 | BranchName: node.Ref.Name, |
| 84 | URL: fmt.Sprintf("%s/tree/%s", node.Ref.Repository.Url, node.Ref.Name), |
| 85 | } |
| 86 | branchNames = append(branchNames, branch) |
| 87 | } |
| 88 | |
| 89 | return branchNames, nil |
| 90 | } |
| 91 | |
| 92 | func CheckLinkedBranchFeature(client *Client, host string) error { |
| 93 | var query struct { |