Skip to content

Commit 2e35968

Browse files
authored
feat(pr): display latest pending update in upgrades table (#13768)
1 parent f579f47 commit 2e35968

File tree

5 files changed

+54
-1
lines changed

5 files changed

+54
-1
lines changed

lib/config/options/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1973,6 +1973,7 @@ const options: RenovateOptions[] = [
19731973
'Current value': '{{{currentValue}}}',
19741974
'New value': '{{{newValue}}}',
19751975
Change: '`{{{displayFrom}}}` -> `{{{displayTo}}}`',
1976+
Pending: '{{{displayPending}}}',
19761977
References: '{{{references}}}',
19771978
'Package file': '{{{packageFile}}}',
19781979
},
@@ -1982,7 +1983,7 @@ const options: RenovateOptions[] = [
19821983
description: 'List of columns to use in PR bodies.',
19831984
type: 'array',
19841985
subType: 'string',
1985-
default: ['Package', 'Type', 'Update', 'Change'],
1986+
default: ['Package', 'Type', 'Update', 'Change', 'Pending'],
19861987
},
19871988
{
19881989
name: 'prBodyNotes',

lib/util/template/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export const allowedFields = {
7777
'The depName field sanitized for use in branches after removing spaces and special characters',
7878
depType: 'The dependency type (if extracted - manager-dependent)',
7979
displayFrom: 'The current value, formatted for display',
80+
displayPending: 'Latest pending update, if internalChecksFilter is in use',
8081
displayTo: 'The to value, formatted for display',
8182
hasReleaseNotes: 'true if the upgrade has release notes',
8283
isLockfileUpdate: 'true if the branch is a lock file update',

lib/workers/repository/updates/__snapshots__/generate.spec.ts.snap

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Object {
1313
"dependencyDashboardApproval": false,
1414
"dependencyDashboardPrApproval": false,
1515
"displayFrom": "",
16+
"displayPending": "",
1617
"displayTo": "0.6.0",
1718
"labels": Array [
1819
"a",
@@ -30,6 +31,7 @@ Object {
3031
"commitMessage": "",
3132
"depName": "some-dep",
3233
"displayFrom": "",
34+
"displayPending": "",
3335
"displayTo": "0.6.0",
3436
"labels": Array [
3537
"a",
@@ -46,6 +48,7 @@ Object {
4648
"datasource": "npm",
4749
"depName": "some-dep",
4850
"displayFrom": "",
51+
"displayPending": "",
4952
"displayTo": "1.0.0",
5053
"labels": Array [
5154
"a",
@@ -60,6 +63,7 @@ Object {
6063
"commitMessage": "",
6164
"depName": "@types/some-dep",
6265
"displayFrom": "",
66+
"displayPending": "",
6367
"displayTo": "0.5.7",
6468
"labels": Array [
6569
"a",
@@ -85,6 +89,7 @@ Object {
8589
"dependencyDashboardApproval": false,
8690
"dependencyDashboardPrApproval": false,
8791
"displayFrom": "",
92+
"displayPending": "",
8893
"displayTo": "0.6.0",
8994
"hasTypes": true,
9095
"isRange": false,
@@ -103,6 +108,7 @@ Object {
103108
"datasource": "npm",
104109
"depName": "some-dep",
105110
"displayFrom": "",
111+
"displayPending": "",
106112
"displayTo": "0.6.0",
107113
"isRange": false,
108114
"newValue": "0.6.0",
@@ -117,6 +123,7 @@ Object {
117123
"datasource": "npm",
118124
"depName": "some-dep",
119125
"displayFrom": "",
126+
"displayPending": "",
120127
"displayTo": "1.0.0",
121128
"isRange": false,
122129
"newValue": "1.0.0",
@@ -132,6 +139,7 @@ Object {
132139
"datasource": "npm",
133140
"depName": "@types/some-dep",
134141
"displayFrom": "0.5.7",
142+
"displayPending": "",
135143
"displayTo": "0.5.8",
136144
"isRange": false,
137145
"newValue": "0.5.8",
@@ -153,6 +161,7 @@ Object {
153161
"dependencyDashboardApproval": false,
154162
"dependencyDashboardPrApproval": false,
155163
"displayFrom": "",
164+
"displayPending": "",
156165
"displayTo": "",
157166
"isLockFileMaintenance": true,
158167
"labels": Array [],
@@ -165,6 +174,7 @@ Object {
165174
"branchName": "some-branch",
166175
"commitMessage": "",
167176
"displayFrom": "",
177+
"displayPending": "",
168178
"displayTo": "",
169179
"isLockFileMaintenance": true,
170180
"prTitle": "some-title",
@@ -186,6 +196,7 @@ Object {
186196
"dependencyDashboardApproval": false,
187197
"dependencyDashboardPrApproval": false,
188198
"displayFrom": "1.0.0",
199+
"displayPending": "",
189200
"displayTo": "1.0.1",
190201
"isLockfileUpdate": true,
191202
"isRange": false,
@@ -204,6 +215,7 @@ Object {
204215
"currentValue": "^1.0.0",
205216
"currentVersion": "1.0.0",
206217
"displayFrom": "1.0.0",
218+
"displayPending": "",
207219
"displayTo": "1.0.1",
208220
"isLockfileUpdate": true,
209221
"isRange": false,

lib/workers/repository/updates/generate.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,5 +657,35 @@ describe('workers/repository/updates/generate', () => {
657657
expect(res.pendingChecks).toBeUndefined();
658658
expect(res.upgrades).toHaveLength(1);
659659
});
660+
it('displays pending versions', () => {
661+
const branch = [
662+
{
663+
depName: 'some-dep',
664+
groupName: 'some-group',
665+
branchName: 'some-branch',
666+
prTitle: 'No pending version',
667+
},
668+
{
669+
depName: 'some-dep',
670+
groupName: 'some-group',
671+
branchName: 'some-branch',
672+
prTitle: 'One pending version',
673+
pendingVersions: ['1.1.0'],
674+
},
675+
{
676+
depName: 'some-dep',
677+
groupName: 'some-group',
678+
branchName: 'some-branch',
679+
prTitle: 'Two pending versions',
680+
pendingVersions: ['1.1.0', '1.1.1'],
681+
},
682+
];
683+
const res = generateBranchConfig(branch);
684+
expect(res.upgrades.map((u) => u.displayPending)).toStrictEqual([
685+
'',
686+
'`1.1.0`',
687+
'`1.1.1` (+1)',
688+
]);
689+
});
660690
});
661691
});

lib/workers/repository/updates/generate.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ export function generateBranchConfig(
124124
}
125125
upgrade.displayFrom ??= '';
126126
upgrade.displayTo ??= '';
127+
const pendingVersionsLength = upgrade.pendingVersions?.length;
128+
if (pendingVersionsLength) {
129+
upgrade.displayPending = `\`${upgrade.pendingVersions.slice(-1).pop()}\``;
130+
if (pendingVersionsLength > 1) {
131+
upgrade.displayPending += ` (+${pendingVersionsLength - 1})`;
132+
}
133+
} else {
134+
upgrade.displayPending = '';
135+
}
127136
upgrade.prettyDepType =
128137
upgrade.prettyDepType || upgrade.depType || 'dependency';
129138
if (useGroupSettings) {

0 commit comments

Comments
 (0)