Skip to content

Commit 94b6cc9

Browse files
committed
prefer tag over digest for displaying
1 parent bb4ec3f commit 94b6cc9

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

app/model/container.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,34 @@ test('addUpdateKindProperty should detect digest update', async () => {
713713
});
714714
});
715715

716+
test('addUpdateKindProperty should prefer tag update over digest update', async () => {
717+
const { testable_addUpdateKindProperty: addUpdateKindProperty } = container;
718+
const containerObject = {
719+
updateAvailable: true,
720+
image: {
721+
tag: {
722+
value: '1.0.0',
723+
semver: true,
724+
},
725+
digest: {
726+
watch: true,
727+
value: 'sha256:123465789',
728+
},
729+
},
730+
result: {
731+
tag: '1.0.1',
732+
digest: 'sha256:987654321',
733+
},
734+
};
735+
addUpdateKindProperty(containerObject);
736+
expect(containerObject.updateKind).toEqual({
737+
kind: 'tag',
738+
localValue: '1.0.0',
739+
remoteValue: '1.0.1',
740+
semverDiff: 'patch',
741+
});
742+
});
743+
716744
test('addUpdateKindProperty should return unknown when no image or result', async () => {
717745
const { testable_addUpdateKindProperty: addUpdateKindProperty } = container;
718746
const containerObject = {};

app/model/container.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,15 +333,21 @@ function getRawUpdateKind(container: Container): ContainerUpdateKind {
333333
return unknownUpdateKind;
334334
}
335335

336-
// Digest watch mode takes precedence over tag-based updates.
336+
// Prefer tag updates when both tag and digest updates are present.
337+
const tagUpdate = getRawTagUpdate(container);
338+
if (tagUpdate.kind === 'tag') {
339+
return tagUpdate;
340+
}
341+
337342
if (
338343
container.image.digest?.watch &&
339344
container.image.digest.value !== undefined &&
340345
container.result.digest !== undefined
341346
) {
342347
return getRawDigestUpdate(container);
343348
}
344-
return getRawTagUpdate(container);
349+
350+
return tagUpdate;
345351
}
346352

347353
function hasRawUpdate(container: Container): boolean {

0 commit comments

Comments
 (0)