Skip to content

Commit

Permalink
fix(manage-merge-queue): ensure queued for merge label is applied
Browse files Browse the repository at this point in the history
  • Loading branch information
danadajian committed Aug 9, 2024
1 parent 1a0754f commit 0de8ed1
Show file tree
Hide file tree
Showing 4 changed files with 274 additions and 148 deletions.
10 changes: 6 additions & 4 deletions dist/676.index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/676.index.js.map

Large diffs are not rendered by default.

14 changes: 10 additions & 4 deletions src/helpers/manage-merge-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const manageMergeQueue = async ({
return removePrFromQueue(pullRequest);
}
const queuedPrs = await getQueuedPullRequests();
const queuePosition = queuedPrs.length;
const queuePosition = queuedPrs.length + 1;

if (queuePosition > Number(max_queue_size)) {
await createPrComment({
Expand All @@ -74,7 +74,7 @@ export const manageMergeQueue = async ({
if (pullRequest.labels.find(label => label.name === JUMP_THE_QUEUE_PR_LABEL)) {
if (allow_only_for_maintainers === 'true') {
const isMaintainer = await isUserInTeam({ team: team });
if (isMaintainer != true) {
if (!isMaintainer) {
await removeLabelIfExists(JUMP_THE_QUEUE_PR_LABEL, pullRequest.number);
return await createPrComment({
body: `Only core maintainers can jump the queue. Please have a core maintainer jump the queue for you`
Expand All @@ -84,7 +84,9 @@ export const manageMergeQueue = async ({

return updateMergeQueue(queuedPrs);
}
if (!pullRequest.labels.find(label => label.name?.startsWith(QUEUED_FOR_MERGE_PREFIX))) {

const prIsAlreadyInTheQueue = pullRequest.labels.find(label => label.name?.startsWith(QUEUED_FOR_MERGE_PREFIX));
if (!prIsAlreadyInTheQueue) {
await addPrToQueue(pullRequest, queuePosition, skip_auto_merge);
}

Expand Down Expand Up @@ -143,7 +145,11 @@ const addPrToQueue = async (pullRequest: PullRequest, queuePosition: number, ski

const getQueuedPullRequests = async (): Promise<PullRequestList> => {
const openPullRequests = await paginateAllOpenPullRequests();
return openPullRequests.filter(pr => pr.labels.some(label => label.name === READY_FOR_MERGE_PR_LABEL));
return openPullRequests.filter(
pr =>
pr.labels.some(label => label.name === READY_FOR_MERGE_PR_LABEL) &&
pr.labels.some(label => label.name.startsWith(QUEUED_FOR_MERGE_PREFIX))
);
};

export const enableAutoMerge = async (pullRequestId: string, mergeMethod = 'SQUASH') => {
Expand Down
Loading

0 comments on commit 0de8ed1

Please sign in to comment.