Add PR auto-merge status info to PR queries (#7384)

This commit is contained in:
Martijn Pieters 2023-05-03 22:36:21 +01:00 committed by GitHub
parent d349ba185a
commit bf3ffba8ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View file

@ -39,6 +39,8 @@ type PullRequest struct {
ClosedAt *time.Time
MergedAt *time.Time
AutoMergeRequest *AutoMergeRequest
MergeCommit *Commit
PotentialMergeCommit *Commit
@ -136,6 +138,16 @@ type PRRepository struct {
Name string `json:"name"`
}
type AutoMergeRequest struct {
AuthorEmail *string `json:"authorEmail"`
CommitBody *string `json:"commitBody"`
CommitHeadline *string `json:"commitHeadline"`
// MERGE, REBASE, SQUASH
MergeMethod string `json:"mergeMethod"`
EnabledAt time.Time `json:"enabledAt"`
EnabledBy Author `json:"enabledBy"`
}
// Commit loads just the commit SHA and nothing else
type Commit struct {
OID string `json:"oid"`

View file

@ -132,6 +132,17 @@ var prCommits = shortenQuery(`
}
`)
var autoMergeRequest = shortenQuery(`
autoMergeRequest {
authorEmail,
commitBody,
commitHeadline,
mergeMethod,
enabledAt,
enabledBy{login,...on User{id,name}}
}
`)
func StatusCheckRollupGraphQL(after string) string {
var afterClause string
if after != "" {
@ -231,6 +242,7 @@ var IssueFields = []string{
var PullRequestFields = append(IssueFields,
"additions",
"autoMergeRequest",
"baseRefName",
"changedFiles",
"commits",
@ -285,6 +297,8 @@ func IssueGraphQL(fields []string) string {
q = append(q, `mergeCommit{oid}`)
case "potentialMergeCommit":
q = append(q, `potentialMergeCommit{oid}`)
case "autoMergeRequest":
q = append(q, autoMergeRequest)
case "comments":
q = append(q, issueComments)
case "lastComment": // pseudo-field