MCPcopy Index your code
hub / github.com/cli/cli / ListLinkedBranches

Function ListLinkedBranches

api/queries_branch_issue_reference.go:51–90  ·  view source on GitHub ↗
(client *Client, repo ghrepo.Interface, issueNumber int)

Source from the content-addressed store, hash-verified

49}
50
51func 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
92func CheckLinkedBranchFeature(client *Client, host string) error {
93 var query struct {

Callers 2

developRunCreateFunction · 0.92
developRunListFunction · 0.92

Calls 5

RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
QueryMethod · 0.65
RepoHostMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected