fix(pr): intelligently merge prBodyColumns (#14198)

This commit is contained in:
Rhys Arkins 2022-02-13 09:26:49 +01:00 committed by GitHub
parent 766d92144f
commit c6b1cda575
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 0 deletions

View file

@ -21,6 +21,7 @@ Object {
"b",
],
"newValue": "0.6.0",
"prBodyColumns": Array [],
"prTitle": "some-title",
"prettyDepType": "dependency",
"releaseTimestamp": undefined,
@ -95,6 +96,7 @@ Object {
"isRange": false,
"labels": Array [],
"newValue": "0.6.0",
"prBodyColumns": Array [],
"prTitle": "some-title",
"prettyDepType": "dependency",
"recreateClosed": false,
@ -165,6 +167,7 @@ Object {
"displayTo": "",
"isLockFileMaintenance": true,
"labels": Array [],
"prBodyColumns": Array [],
"prTitle": "some-title",
"prettyDepType": "dependency",
"releaseTimestamp": undefined,
@ -204,6 +207,7 @@ Object {
"lockedVersion": "1.0.0",
"newValue": "^1.0.0",
"newVersion": "1.0.1",
"prBodyColumns": Array [],
"prTitle": "some-title",
"prettyDepType": "dependency",
"releaseTimestamp": undefined,

View file

@ -660,6 +660,20 @@ describe('workers/repository/updates/generate', () => {
const res = generateBranchConfig(branch);
expect(res.prTitle).toMatchSnapshot('some-title (patch)');
});
it('combines prBodyColumns', () => {
const branch: BranchUpgradeConfig[] = [
{
branchName: 'some-branch',
prBodyColumns: ['column-a', 'column-b'],
},
{
branchName: 'some-branch',
prBodyColumns: ['column-c', 'column-b', 'column-a'],
},
];
const res = generateBranchConfig(branch);
expect(res.prBodyColumns).toEqual(['column-a', 'column-b', 'column-c']);
});
it('sorts upgrades, without position first', () => {
const branch: BranchUpgradeConfig[] = [
{

View file

@ -1,3 +1,4 @@
import is from '@sindresorhus/is';
import { DateTime } from 'luxon';
import mdTable from 'markdown-table';
import semver from 'semver';
@ -305,6 +306,14 @@ export function generateBranchConfig(
config.dependencyDashboardPrApproval = config.upgrades.some(
(upgrade) => upgrade.prCreation === 'approval'
);
config.prBodyColumns = [
...new Set(
config.upgrades.reduce(
(existing, upgrade) => existing.concat(upgrade.prBodyColumns),
[]
)
),
].filter(is.nonEmptyString);
config.automerge = config.upgrades.every((upgrade) => upgrade.automerge);
// combine all labels
config.labels = [