Skip to content

Commit

Permalink
fix: base ref
Browse files Browse the repository at this point in the history
  • Loading branch information
msvticket committed Nov 18, 2024
1 parent b7d99c7 commit 4186bab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions pkg/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -1888,6 +1891,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 == "" {
Expand Down Expand Up @@ -1917,7 +1923,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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 4186bab

Please sign in to comment.