fix: immortal digest groups (#18402)

This commit is contained in:
Rhys Arkins 2022-10-19 10:17:16 +02:00 committed by GitHub
parent 908be27404
commit 5dfc850b3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 52 additions and 22 deletions

View file

@ -238,6 +238,36 @@ describe('workers/repository/updates/generate', () => {
expect(res.recreateClosed).toBeFalsy(); expect(res.recreateClosed).toBeFalsy();
}); });
it('groups multiple digest updates immortally', () => {
const branch: BranchUpgradeConfig[] = [
{
manager: 'some-manager',
depName: 'some-dep',
groupName: 'some-group',
branchName: 'some-branch',
prTitle: 'some-title',
commitMessageExtra: 'to {{{newDigestShort}}}',
newValue: '5.1.2',
newDigest: 'sha256:abcdef123',
isDigest: true,
},
{
manager: 'some-manager',
depName: 'some-other-dep',
groupName: 'some-group',
branchName: 'some-branch',
prTitle: 'some-title',
commitMessageExtra: 'to {{{newDigestShort}}}',
newValue: '5.2.0',
newDigest: 'sha256:abcdef987654321',
isDigest: true,
},
];
const res = generateBranchConfig(branch);
expect(res.groupName).toBeDefined();
expect(res.recreateClosed).toBeTrue();
});
it('groups multiple upgrades different version', () => { it('groups multiple upgrades different version', () => {
const branch: BranchUpgradeConfig[] = [ const branch: BranchUpgradeConfig[] = [
{ {

View file

@ -83,6 +83,28 @@ export function generateBranchConfig(
const toVersions: string[] = []; const toVersions: string[] = [];
const toValues = new Set<string>(); const toValues = new Set<string>();
for (const upg of branchUpgrades) { for (const upg of branchUpgrades) {
if (upg.currentDigest) {
upg.currentDigestShort =
upg.currentDigestShort ??
upg.currentDigest.replace('sha256:', '').substring(0, 7);
}
if (upg.newDigest) {
upg.newDigestShort =
upg.newDigestShort ||
upg.newDigest.replace('sha256:', '').substring(0, 7);
}
if (upg.isDigest || upg.isPinDigest) {
upg.displayFrom = upg.currentDigestShort;
upg.displayTo = upg.newDigestShort;
} else if (upg.isLockfileUpdate) {
upg.displayFrom = upg.currentVersion;
upg.displayTo = upg.newVersion;
} else if (!upg.isLockFileMaintenance) {
upg.displayFrom = upg.currentValue;
upg.displayTo = upg.newValue;
}
upg.displayFrom ??= '';
upg.displayTo ??= '';
if (!depNames.includes(upg.depName!)) { if (!depNames.includes(upg.depName!)) {
depNames.push(upg.depName!); depNames.push(upg.depName!);
} }
@ -123,28 +145,6 @@ export function generateBranchConfig(
upgrade.commitMessageExtra = `to v${toVersions[0]}`; upgrade.commitMessageExtra = `to v${toVersions[0]}`;
} }
if (upgrade.currentDigest) {
upgrade.currentDigestShort =
upgrade.currentDigestShort ??
upgrade.currentDigest.replace('sha256:', '').substring(0, 7);
}
if (upgrade.newDigest) {
upgrade.newDigestShort =
upgrade.newDigestShort ||
upgrade.newDigest.replace('sha256:', '').substring(0, 7);
}
if (upgrade.isDigest || upgrade.isPinDigest) {
upgrade.displayFrom = upgrade.currentDigestShort;
upgrade.displayTo = upgrade.newDigestShort;
} else if (upgrade.isLockfileUpdate) {
upgrade.displayFrom = upgrade.currentVersion;
upgrade.displayTo = upgrade.newVersion;
} else if (!upgrade.isLockFileMaintenance) {
upgrade.displayFrom = upgrade.currentValue;
upgrade.displayTo = upgrade.newValue;
}
upgrade.displayFrom ??= '';
upgrade.displayTo ??= '';
const pendingVersionsLength = upgrade.pendingVersions?.length; const pendingVersionsLength = upgrade.pendingVersions?.length;
if (pendingVersionsLength) { if (pendingVersionsLength) {
upgrade.displayPending = `\`${upgrade upgrade.displayPending = `\`${upgrade