From 18a0964b0a4e705b17676772739d0c74473bc31f Mon Sep 17 00:00:00 2001 From: Bartosz Majsak Date: Sat, 7 Dec 2019 08:46:48 +0100 Subject: [PATCH] fix: uses defaultBranchRef instead of hardcoded master --- pkg/github/client.go | 60 +++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/pkg/github/client.go b/pkg/github/client.go index 7f94fd4..d70a7c0 100644 --- a/pkg/github/client.go +++ b/pkg/github/client.go @@ -28,37 +28,39 @@ func CreateClient() *githubv4.Client { type AssociatedPRsQuery struct { Repository struct { - Object struct { - Commit struct { - Oid string - History struct { - Nodes []struct { - Oid string - MessageHeadline string - Author struct { - User struct { - Login string - } - } - AssociatedPullRequests struct { - Nodes []struct { - Title string - Number int - Permalink string - Author struct { + DefaultBranch struct { + Target struct { + Commit struct { + Oid string + History struct { + Nodes []struct { + Oid string + MessageHeadline string + Author struct { + User struct { Login string } - Labels struct { - Nodes []struct { - Name string - } - } `graphql:"labels(first: 8)"` } - } `graphql:"associatedPullRequests(first: 4)"` - } - } `graphql:"history(since: $createdAt)"` - } `graphql:"... on Commit"` - } `graphql:"object(expression: \"master\")"` + AssociatedPullRequests struct { + Nodes []struct { + Title string + Number int + Permalink string + Author struct { + Login string + } + Labels struct { + Nodes []struct { + Name string + } + } `graphql:"labels(first: 8)"` + } + } `graphql:"associatedPullRequests(first: 4)"` + } + } `graphql:"history(since: $createdAt)"` + } `graphql:"... on Commit"` + } `graphql:"target"` + } `graphql:"defaultBranchRef"` } `graphql:"repository(owner: $owner, name: $name)"` } @@ -94,7 +96,7 @@ func FindAssociatedPRs(client *githubv4.Client, repo []string, matchingCommit Ma check.IfError(err) var prs []PullRequest - for _, node := range associatedPRs.Repository.Object.Commit.History.Nodes { + for _, node := range associatedPRs.Repository.DefaultBranch.Target.Commit.History.Nodes { if node.Oid != matchingCommit.Repository.Object.Commit.Oid && node.MessageHeadline != "release: next iteration" { for _, pr := range node.AssociatedPullRequests.Nodes { if len(pr.Labels.Nodes) == 0 {