diff --git a/lib/workers/repository/process/sort.spec.ts b/lib/workers/repository/process/sort.spec.ts index f22d57a4ba..07ff392ecb 100644 --- a/lib/workers/repository/process/sort.spec.ts +++ b/lib/workers/repository/process/sort.spec.ts @@ -100,5 +100,43 @@ describe('workers/repository/process/sort', () => { { prPriority: -1, prTitle: 'some pin', updateType: 'pin' }, ]); }); + + it('sorts based on isVulnerabilityAlert symmetric', () => { + const branches = [ + { + updateType: 'minor' as UpdateType, + prTitle: 'a minor update', + prPriority: -1, + isVulnerabilityAlert: true, + }, + { + updateType: 'major' as UpdateType, + prTitle: 'some major update', + prPriority: 1, + }, + { + updateType: 'pin' as UpdateType, + prTitle: 'some pin', + prPriority: -1, + }, + { + updateType: 'pin' as UpdateType, + prTitle: 'some other pin', + prPriority: 0, + }, + ]; + sortBranches(branches); + expect(branches).toEqual([ + { + isVulnerabilityAlert: true, + prPriority: -1, + prTitle: 'a minor update', + updateType: 'minor', + }, + { prPriority: 1, prTitle: 'some major update', updateType: 'major' }, + { prPriority: 0, prTitle: 'some other pin', updateType: 'pin' }, + { prPriority: -1, prTitle: 'some pin', updateType: 'pin' }, + ]); + }); }); }); diff --git a/lib/workers/repository/process/sort.ts b/lib/workers/repository/process/sort.ts index 2286dca3d9..bd12206188 100644 --- a/lib/workers/repository/process/sort.ts +++ b/lib/workers/repository/process/sort.ts @@ -16,6 +16,10 @@ export function sortBranches(branches: Partial[]): void { if (a.isVulnerabilityAlert && !b.isVulnerabilityAlert) { return -1; } + if (!a.isVulnerabilityAlert && b.isVulnerabilityAlert) { + return 1; + } + // TODO #7154 if (a.prPriority !== b.prPriority) { return b.prPriority! - a.prPriority!;