mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 07:26:26 +00:00
refactor: always set currentVersionTimestamp (#28949)
This commit is contained in:
parent
a91abaa54e
commit
b5ea61b435
2 changed files with 33 additions and 17 deletions
|
@ -3155,6 +3155,7 @@ describe('workers/repository/process/lookup/index', () => {
|
|||
|
||||
expect(res).toEqual({
|
||||
currentVersion: '1.3.0',
|
||||
currentVersionTimestamp: '2015-04-26T16:42:11.311Z',
|
||||
fixedVersion: '1.3.0',
|
||||
isSingleVersion: true,
|
||||
registryUrl: 'https://registry.npmjs.org',
|
||||
|
@ -3195,6 +3196,7 @@ describe('workers/repository/process/lookup/index', () => {
|
|||
).unwrapOrThrow();
|
||||
expect(res).toEqual({
|
||||
currentVersion: '1.3.0',
|
||||
currentVersionTimestamp: '2015-04-26T16:42:11.311Z',
|
||||
fixedVersion: '1.3.0',
|
||||
isSingleVersion: true,
|
||||
registryUrl: 'https://registry.npmjs.org',
|
||||
|
@ -3247,6 +3249,7 @@ describe('workers/repository/process/lookup/index', () => {
|
|||
|
||||
expect(res).toEqual({
|
||||
currentVersion: '1.3.0',
|
||||
currentVersionTimestamp: '2015-04-26T16:42:11.311Z',
|
||||
deprecationMessage: codeBlock`
|
||||
On registry \`https://registry.npmjs.org\`, the "latest" version of dependency \`q3\` has the following deprecation notice:
|
||||
|
||||
|
@ -4039,14 +4042,15 @@ describe('workers/repository/process/lookup/index', () => {
|
|||
allowedVersions: '< 19.0.0',
|
||||
},
|
||||
];
|
||||
const releaseTimestamp = new Date(
|
||||
Date.now() - 25 * 60 * 60 * 1000,
|
||||
).toISOString();
|
||||
getDockerReleases.mockResolvedValueOnce({
|
||||
releases: [
|
||||
{
|
||||
version: '17.0.0',
|
||||
// a day old release
|
||||
releaseTimestamp: new Date(
|
||||
Date.now() - 25 * 60 * 60 * 1000,
|
||||
).toISOString(),
|
||||
releaseTimestamp,
|
||||
},
|
||||
{
|
||||
version: '18.0.0',
|
||||
|
@ -4063,6 +4067,7 @@ describe('workers/repository/process/lookup/index', () => {
|
|||
|
||||
expect(res).toEqual({
|
||||
currentVersion: '17.0.0',
|
||||
currentVersionTimestamp: releaseTimestamp,
|
||||
fixedVersion: '17.0.0',
|
||||
isSingleVersion: true,
|
||||
registryUrl: 'https://index.docker.io',
|
||||
|
@ -4078,7 +4083,6 @@ describe('workers/repository/process/lookup/index', () => {
|
|||
],
|
||||
versioning: 'docker',
|
||||
warnings: [],
|
||||
currentVersionTimestamp: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -36,6 +36,17 @@ import {
|
|||
isReplacementRulesConfigured,
|
||||
} from './utils';
|
||||
|
||||
function getTimestamp(
|
||||
versions: Release[],
|
||||
version: string,
|
||||
versioning: allVersioning.VersioningApi,
|
||||
): string | null | undefined {
|
||||
return versions.find(
|
||||
(v) =>
|
||||
versioning.isValid(v.version) && versioning.equals(v.version, version),
|
||||
)?.releaseTimestamp;
|
||||
}
|
||||
|
||||
export async function lookupUpdates(
|
||||
inconfig: LookupUpdateConfig,
|
||||
): Promise<Result<UpdateResult, Error>> {
|
||||
|
@ -287,21 +298,22 @@ export async function lookupUpdates(
|
|||
}
|
||||
|
||||
res.currentVersion = currentVersion!;
|
||||
const currentVersionTimestamp = allVersions.find(
|
||||
(v) =>
|
||||
versioning.isValid(v.version) &&
|
||||
versioning.equals(v.version, currentVersion),
|
||||
)?.releaseTimestamp;
|
||||
const currentVersionTimestamp = getTimestamp(
|
||||
allVersions,
|
||||
currentVersion,
|
||||
versioning,
|
||||
);
|
||||
|
||||
if (
|
||||
is.nonEmptyString(currentVersionTimestamp) &&
|
||||
config.packageRules?.some((rules) =>
|
||||
is.nonEmptyString(rules.matchCurrentAge),
|
||||
)
|
||||
) {
|
||||
if (is.nonEmptyString(currentVersionTimestamp)) {
|
||||
res.currentVersionTimestamp = currentVersionTimestamp;
|
||||
// Reapply package rules to check matches for matchCurrentAge
|
||||
config = applyPackageRules({ ...config, currentVersionTimestamp });
|
||||
if (
|
||||
config.packageRules?.some((rules) =>
|
||||
is.nonEmptyString(rules.matchCurrentAge),
|
||||
)
|
||||
) {
|
||||
// Reapply package rules to check matches for matchCurrentAge
|
||||
config = applyPackageRules({ ...config, currentVersionTimestamp });
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
|
|
Loading…
Reference in a new issue