This commit is contained in:
Jonas Rutishauser 2025-01-08 16:28:34 +01:00 committed by GitHub
commit 2c9d3660f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 0 deletions

View file

@ -4947,6 +4947,29 @@ describe('workers/repository/process/lookup/index', () => {
]);
});
it('handles replacements - from datasource', async () => {
config.currentValue = '2.0.0';
config.packageName = 'org.example:foo';
config.datasource = MavenDatasource.id;
getMavenReleases.mockResolvedValueOnce({
releases: [{ version: '2.0.0' }],
replacementName: 'foo:bar',
replacementVersion: '2.0.0',
});
const { updates } = await Result.wrap(
lookup.lookupUpdates(config),
).unwrapOrThrow();
expect(updates).toEqual([
{
updateType: 'replacement',
newName: 'foo:bar',
newValue: '2.0.0',
},
]);
});
it('rollback for invalid version to last stable version', async () => {
config.currentValue = '2.5.17';
config.packageName = 'vue';

View file

@ -571,6 +571,12 @@ export async function lookupUpdates(
if (isReplacementRulesConfigured(config)) {
addReplacementUpdateIfValid(res.updates, config);
} else if (dependency?.replacementName && dependency.replacementVersion) {
res.updates.push({
updateType: 'replacement',
newName: dependency.replacementName,
newValue: dependency.replacementVersion,
});
}
// Record if the dep is fixed to a version