mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-25 14:06:27 +00:00
feat: abandoned (#18785)
This commit is contained in:
parent
496c7f09b7
commit
4e5f6c5266
2 changed files with 30 additions and 5 deletions
|
@ -99,22 +99,38 @@ describe('workers/repository/finalise/prune', () => {
|
|||
expect(platform.updatePr).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('posts comment if someone pushed to PR', async () => {
|
||||
it('notifies via PR changes if someone pushed to PR', async () => {
|
||||
config.branchList = ['renovate/a', 'renovate/b'];
|
||||
git.getBranchList.mockReturnValueOnce(
|
||||
config.branchList.concat(['renovate/c'])
|
||||
);
|
||||
platform.getBranchPr.mockResolvedValueOnce({} as never);
|
||||
git.isBranchModified.mockResolvedValueOnce(true);
|
||||
platform.findPr.mockResolvedValueOnce({ title: 'foo' } as never);
|
||||
platform.findPr.mockResolvedValueOnce({
|
||||
title: 'foo',
|
||||
} as never);
|
||||
await cleanup.pruneStaleBranches(config, config.branchList);
|
||||
expect(git.getBranchList).toHaveBeenCalledTimes(1);
|
||||
expect(git.deleteBranch).toHaveBeenCalledTimes(0);
|
||||
expect(platform.updatePr).toHaveBeenCalledTimes(0);
|
||||
expect(platform.updatePr).toHaveBeenCalledTimes(1);
|
||||
expect(platform.ensureComment).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('skips comment if dry run', async () => {
|
||||
it('skips appending - abandoned to PR title if already present', async () => {
|
||||
config.branchList = ['renovate/a', 'renovate/b'];
|
||||
git.getBranchList.mockReturnValueOnce(
|
||||
config.branchList.concat(['renovate/c'])
|
||||
);
|
||||
platform.getBranchPr.mockResolvedValueOnce({} as never);
|
||||
git.isBranchModified.mockResolvedValueOnce(true);
|
||||
platform.findPr.mockResolvedValueOnce({
|
||||
title: 'foo - abandoned',
|
||||
} as never);
|
||||
await cleanup.pruneStaleBranches(config, config.branchList);
|
||||
expect(platform.updatePr).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('skips changes to PR if dry run', async () => {
|
||||
config.branchList = ['renovate/a', 'renovate/b'];
|
||||
GlobalConfig.set({ dryRun: 'full' });
|
||||
git.getBranchList.mockReturnValueOnce(
|
||||
|
|
|
@ -33,8 +33,17 @@ async function cleanUpBranches(
|
|||
'Branch is modified - skipping PR autoclosing'
|
||||
);
|
||||
if (GlobalConfig.get('dryRun')) {
|
||||
logger.info(`DRY-RUN: Would add Autoclosing Skipped comment to PR`);
|
||||
logger.info(`DRY-RUN: Would update PR title and ensure comment.`);
|
||||
} else {
|
||||
if (!pr.title.endsWith('- abandoned')) {
|
||||
const newPrTitle = pr.title + ' - abandoned';
|
||||
await platform.updatePr({
|
||||
number: pr.number,
|
||||
prTitle: newPrTitle,
|
||||
state: PrState.Open,
|
||||
});
|
||||
}
|
||||
|
||||
await ensureComment({
|
||||
number: pr.number,
|
||||
topic: 'Autoclosing Skipped',
|
||||
|
|
Loading…
Reference in a new issue