Skip to content

Commit

Permalink
fix: Avoid rejecting releases when extractVersion is used (#32376)
Browse files Browse the repository at this point in the history
  • Loading branch information
zharinov authored Nov 7, 2024
1 parent 8bbba57 commit b8835e4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/modules/datasource/postprocess-release.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,31 @@ describe('modules/datasource/postprocess-release', () => {
expect(release).toBeNull();
});

it('preserves rejected release when `extractVersion` was set', async () => {
const releaseOrig: Release = { version: '1.2.3' };

class SomeDatasource extends DummyDatasource {
override postprocessRelease(
_config: PostprocessReleaseConfig,
_release: Release,
): Promise<PostprocessReleaseResult> {
return Promise.resolve('reject');
}
}
getDatasourceFor.mockReturnValueOnce(new SomeDatasource());

const release = await postprocessRelease(
{
datasource: 'some-datasource',
packageName: 'some-package',
extractVersion: '^(?<version>\\d+)$',
},
releaseOrig,
);

expect(release).toBe(releaseOrig);
});

it('falls back when error was thrown', async () => {
const releaseOrig: Release = { version: '1.2.3' };

Expand Down
14 changes: 14 additions & 0 deletions lib/modules/datasource/postprocess-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ export async function postprocessRelease(
);

if (result === 'reject') {
if (config.extractVersion) {
logger.debug(
{
datasource,
packageName,
registryUrl,
version: release.version,
extractVersion: config.extractVersion,
},
'Rejected release combined with `extractVersion`: preserving the release',
);
return release;
}

logger.debug(
{ datasource, packageName, registryUrl, version: release.version },
'Rejected release',
Expand Down

0 comments on commit b8835e4

Please # to comment.