Skip to content

Commit

Permalink
fix: uses defaultBranchRef instead of hardcoded master
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszmajsak committed Dec 7, 2019
1 parent af41135 commit 18a0964
Showing 1 changed file with 31 additions and 29 deletions.
60 changes: 31 additions & 29 deletions pkg/github/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)"`
}

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 18a0964

Please sign in to comment.