feat(pr): remove and re-create automergeComment when rebasing (#6002)

This commit is contained in:
Björn Brauer 2020-05-14 13:13:38 +02:00 committed by GitHub
parent 957980051f
commit 8144f07b69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View file

@ -85,6 +85,18 @@ describe('workers/pr', () => {
pr.isModified = false; pr.isModified = false;
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.green); platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.green);
await prWorker.checkAutoMerge(pr, config); await prWorker.checkAutoMerge(pr, config);
expect(platform.ensureCommentRemoval).toHaveBeenCalledTimes(0);
expect(platform.ensureComment).toHaveBeenCalledTimes(1);
});
it('should remove previous automerge comment when rebasing', async () => {
config.automerge = true;
config.automergeType = 'pr-comment';
config.automergeComment = '!merge';
config.rebaseRequested = true;
pr.isModified = false;
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.green);
await prWorker.checkAutoMerge(pr, config);
expect(platform.ensureCommentRemoval).toHaveBeenCalledTimes(1);
expect(platform.ensureComment).toHaveBeenCalledTimes(1); expect(platform.ensureComment).toHaveBeenCalledTimes(1);
}); });
it('should not automerge if enabled and pr is mergeable but cannot rebase', async () => { it('should not automerge if enabled and pr is mergeable but cannot rebase', async () => {

View file

@ -437,6 +437,7 @@ export async function checkAutoMerge(
automergeType, automergeType,
automergeComment, automergeComment,
requiredStatusChecks, requiredStatusChecks,
rebaseRequested,
} = config; } = config;
logger.debug( logger.debug(
{ automerge, automergeType, automergeComment }, { automerge, automergeType, automergeComment },
@ -481,6 +482,12 @@ export async function checkAutoMerge(
); );
return false; return false;
} }
if (rebaseRequested) {
await platform.ensureCommentRemoval({
number: pr.number,
content: automergeComment,
});
}
return platform.ensureComment({ return platform.ensureComment({
number: pr.number, number: pr.number,
topic: null, topic: null,