mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 15:01:49 +00:00
c953fafcdc
* 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>
100 lines
2.7 KiB
TypeScript
100 lines
2.7 KiB
TypeScript
import { fakeSha, git } from '~test/util.ts';
|
|
import { PR_ALREADY_IN_MERGE_QUEUE } from '../../../constants/error-messages.ts';
|
|
import type { CommitFilesConfig } from '../../../util/git/types.ts';
|
|
import * as _github from './index.ts';
|
|
import { GithubScm } from './scm.ts';
|
|
|
|
vi.mock('./index.ts');
|
|
const github = vi.mocked(_github);
|
|
|
|
describe('modules/platform/github/scm', () => {
|
|
beforeEach(() => {
|
|
git.commitFiles.mockResolvedValue(fakeSha('sha'));
|
|
});
|
|
|
|
const githubScm = new GithubScm();
|
|
|
|
const commitObj = {
|
|
baseBranch: 'main',
|
|
branchName: 'branch',
|
|
files: [],
|
|
message: 'msg',
|
|
} satisfies CommitFilesConfig;
|
|
|
|
it('platformCommit = disabled => delegate to git', async () => {
|
|
await githubScm.commitAndPush({
|
|
...commitObj,
|
|
platformCommit: 'disabled',
|
|
});
|
|
|
|
expect(git.commitFiles).toHaveBeenCalledExactlyOnceWith({
|
|
...commitObj,
|
|
platformCommit: 'disabled',
|
|
});
|
|
expect(github.commitFiles).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('platformCommit = enabled => delegate to github', async () => {
|
|
await githubScm.commitAndPush({
|
|
...commitObj,
|
|
platformCommit: 'enabled',
|
|
});
|
|
|
|
expect(git.commitFiles).not.toHaveBeenCalled();
|
|
expect(github.commitFiles).toHaveBeenCalledExactlyOnceWith({
|
|
...commitObj,
|
|
platformCommit: 'enabled',
|
|
});
|
|
});
|
|
|
|
it('platformCommit = auto => delegate to git', async () => {
|
|
await githubScm.commitAndPush({
|
|
...commitObj,
|
|
platformCommit: 'auto',
|
|
});
|
|
|
|
expect(git.commitFiles).toHaveBeenCalledExactlyOnceWith({
|
|
...commitObj,
|
|
platformCommit: 'auto',
|
|
});
|
|
expect(github.commitFiles).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('platformCommit = auto and is a github app => delegate to github', async () => {
|
|
github.isGHApp.mockReturnValueOnce(true);
|
|
|
|
await githubScm.commitAndPush({
|
|
...commitObj,
|
|
platformCommit: 'auto',
|
|
});
|
|
|
|
expect(git.commitFiles).not.toHaveBeenCalled();
|
|
expect(github.commitFiles).toHaveBeenCalledExactlyOnceWith({
|
|
...commitObj,
|
|
platformCommit: 'auto',
|
|
});
|
|
});
|
|
|
|
it('checks the merge queue before committing', async () => {
|
|
await githubScm.commitAndPush(commitObj);
|
|
|
|
expect(github.assertPrNotInMergeQueue).toHaveBeenCalledExactlyOnceWith(
|
|
'branch',
|
|
'main',
|
|
);
|
|
});
|
|
|
|
it('does not commit if the branch PR is in the merge queue', async () => {
|
|
github.assertPrNotInMergeQueue.mockRejectedValueOnce(
|
|
new Error(PR_ALREADY_IN_MERGE_QUEUE),
|
|
);
|
|
|
|
await expect(githubScm.commitAndPush(commitObj)).rejects.toThrow(
|
|
PR_ALREADY_IN_MERGE_QUEUE,
|
|
);
|
|
|
|
expect(git.commitFiles).not.toHaveBeenCalled();
|
|
expect(github.commitFiles).not.toHaveBeenCalled();
|
|
});
|
|
});
|