Files
renovate/lib/modules/platform/github/graphql.ts
T
Michael Kriese c953fafcdc fix(platform/github): abort branch update when PR is in merge queue (#45252)
* fix(platform/github): skip PR update when PR is in merge queue

Updating a PR that is queued for merging can remove it from the merge
queue. Check the PR's merge queue status via GraphQL before updating
and skip the update if it is queued. The check is skipped on GHES
<3.12.0 and fails open on errors.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(platform/github): dequeue PR from merge queue instead of skipping update

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs(platform/github): note re-queue behavior after dequeue

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor(platform/github): dequeue merge queue PR in commitAndPush

Dequeue on push instead of on PR metadata update, since pushing to the
branch is what invalidates the queued merge result.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor(platform/github): extract dequeuePr to pr.ts

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(platform/github): abort branch update when PR is in merge queue

Instead of dequeueing the PR, throw PR_ALREADY_IN_MERGE_QUEUE from
commitAndPush and handle it gracefully in processBranch.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(platform/github): check merge queue enablement per base branch

Cache merge queue enablement per base branch like branchForceRebase and
skip the per-PR merge queue check when the base branch has no merge
queue. Errors are treated as enabled.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(platform/github): fetch default branch merge queue status in initRepo

Include mergeQueue in repoInfoQuery so no extra query is needed for the
default branch, stripping it on GHES <3.12.0 like other unsupported
fields.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-14 07:05:12 +00:00

114 lines
2.0 KiB
TypeScript

export const repoInfoQuery = `
query($owner: String!, $name: String!, $user: String) {
repository(owner: $owner, name: $name) {
id
sshUrl
isFork
parent {
nameWithOwner
}
isArchived
nameWithOwner
hasIssuesEnabled
hasVulnerabilityAlertsEnabled
autoMergeAllowed
mergeCommitAllowed
rebaseMergeAllowed
squashMergeAllowed
mergeQueue { id }
defaultBranchRef {
name
target {
oid
}
}
issues(
orderBy: { field: UPDATED_AT, direction: DESC },
filterBy: { createdBy: $user },
first: 5
) {
nodes {
number
state
title
body
updatedAt
}
}
}
}
`;
export const getIssuesQuery = `
query(
$owner: String!,
$name: String!,
$user: String,
$count: Int,
$cursor: String
) {
repository(owner: $owner, name: $name) {
issues(
orderBy: { field: UPDATED_AT, direction: DESC },
filterBy: { createdBy: $user },
first: $count,
after: $cursor
) {
pageInfo {
endCursor
hasNextPage
}
nodes {
number
state
title
body
updatedAt
}
}
}
}
`;
export const repoMergeQueueQuery = `
query($owner: String!, $name: String!, $branch: String!) {
repository(owner: $owner, name: $name) {
mergeQueue(branch: $branch) {
id
}
}
}
`;
export const prIsInMergeQueueQuery = `
query($owner: String!, $name: String!, $number: Int!) {
repository(owner: $owner, name: $name) {
pullRequest(number: $number) {
isInMergeQueue
}
}
}
`;
export const enableAutoMergeMutation = `
mutation EnablePullRequestAutoMerge(
$pullRequestId: ID!,
$mergeMethod: PullRequestMergeMethod!,
$commitHeadline: String,
$commitBody: String,
) {
enablePullRequestAutoMerge(
input: {
pullRequestId: $pullRequestId,
mergeMethod: $mergeMethod,
commitHeadline: $commitHeadline,
commitBody: $commitBody,
}
) {
pullRequest {
number
}
}
}
`;