mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
fix(workers): guarantee symmetric result from sort branch predicate (#18275)
This commit is contained in:
parent
61f8c9895f
commit
e6c43aae81
2 changed files with 42 additions and 0 deletions
|
@ -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' },
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -16,6 +16,10 @@ export function sortBranches(branches: Partial<BranchConfig>[]): 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!;
|
||||
|
|
Loading…
Reference in a new issue