From e79f0f1230bafb9a800fd5d3589bbd4b41bcce0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Svantesson?= Date: Mon, 18 Nov 2024 19:30:37 +0100 Subject: [PATCH] fix: base ref --- pkg/keeper/keeper.go | 10 +++++++--- pkg/keeper/keeper_test.go | 2 +- pkg/keeper/status_test.go | 9 +++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/pkg/keeper/keeper.go b/pkg/keeper/keeper.go index 05fc35f4e..d67f57909 100644 --- a/pkg/keeper/keeper.go +++ b/pkg/keeper/keeper.go @@ -1539,7 +1539,7 @@ func (c *DefaultController) dividePool(pool map[string]PullRequest, pjs []v1alph repo := string(pr.Repository.Name) branch := string(pr.BaseRef.Name) cloneURL := string(pr.Repository.URL) - baseSHA := string(pr.BaseRefOID) + baseSHA := string(pr.BaseRef.Target.OID) if cloneURL == "" { return nil, errors.New("no clone URL specified for repository") } @@ -1587,6 +1587,9 @@ type GraphQLAuthor struct { type GraphQLBaseRef struct { Name githubql.String Prefix githubql.String + Target struct { + OID githubql.String `graphql:"oid"` + } } // PullRequest holds graphql data about a PR, including its commits and their contexts. @@ -1596,7 +1599,6 @@ type PullRequest struct { BaseRef GraphQLBaseRef HeadRefName githubql.String `graphql:"headRefName"` HeadRefOID githubql.String `graphql:"headRefOid"` - BaseRefOID githubql.String Mergeable githubql.MergeableState Repository Repository Commits struct { @@ -1888,6 +1890,9 @@ func scmPRToGraphQLPR(scmPR *scm.PullRequest, scmRepo *scm.Repository) *PullRequ baseRef := GraphQLBaseRef{ Name: githubql.String(scmPR.Target), Prefix: githubql.String(strings.TrimSuffix(scmPR.Base.Ref, scmPR.Target)), + Target: struct { + OID githubql.String `graphql:"oid"` + }{OID: githubql.String(scmPR.Base.Sha)}, } if baseRef.Prefix == "" { @@ -1917,7 +1922,6 @@ func scmPRToGraphQLPR(scmPR *scm.PullRequest, scmRepo *scm.Repository) *PullRequ BaseRef: baseRef, HeadRefName: githubql.String(scmPR.Source), HeadRefOID: githubql.String(scmPR.Head.Sha), - BaseRefOID: githubql.String(scmPR.Base.Sha), Mergeable: mergeable, Repository: scmRepoToGraphQLRepo(scmRepo), Labels: labels, diff --git a/pkg/keeper/keeper_test.go b/pkg/keeper/keeper_test.go index f2cf98327..e916da92c 100644 --- a/pkg/keeper/keeper_test.go +++ b/pkg/keeper/keeper_test.go @@ -764,7 +764,7 @@ func TestDividePool(t *testing.T) { npr := PullRequest{Number: githubql.Int(p.number)} npr.BaseRef.Name = githubql.String(p.branch) npr.BaseRef.Prefix = "refs/heads/" - npr.BaseRefOID = githubql.String(testPJs[idx].baseSHA) + npr.BaseRef.Target.OID = githubql.String(testPJs[idx].baseSHA) npr.Repository.Name = githubql.String(p.repo) npr.Repository.Owner.Login = githubql.String(p.org) npr.Repository.URL = githubql.String(fmt.Sprintf("https://github.com/%s/%s.git", p.org, p.repo)) diff --git a/pkg/keeper/status_test.go b/pkg/keeper/status_test.go index 03cd73a8e..bdb660b2c 100644 --- a/pkg/keeper/status_test.go +++ b/pkg/keeper/status_test.go @@ -259,10 +259,7 @@ func TestExpectedStatus(t *testing.T) { secondQuery, }.QueryMap() var pr PullRequest - pr.BaseRef = struct { - Name githubql.String - Prefix githubql.String - }{ + pr.BaseRef = GraphQLBaseRef{ Name: githubql.String(tc.baseref), } for _, label := range tc.labels { @@ -272,7 +269,7 @@ func TestExpectedStatus(t *testing.T) { ) } if len(tc.contexts) > 0 { - pr.HeadRefOID = githubql.String("head") + pr.HeadRefOID = "head" pr.Commits.Nodes = append( pr.Commits.Nodes, struct{ Commit Commit }{ @@ -280,7 +277,7 @@ func TestExpectedStatus(t *testing.T) { Status: struct{ Contexts []Context }{ Contexts: tc.contexts, }, - OID: githubql.String("head"), + OID: "head", }, }, )