mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
fix: respect latest only if ignoring unstable
This commit is contained in:
parent
9ec45c7acf
commit
1271414cb0
1 changed files with 21 additions and 24 deletions
|
@ -6,7 +6,6 @@ const {
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
filterVersions,
|
filterVersions,
|
||||||
filterUnstable,
|
|
||||||
filterLatest,
|
filterLatest,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,42 +14,40 @@ function filterVersions(config, fromVersion, latestVersion, versions) {
|
||||||
if (!fromVersion) {
|
if (!fromVersion) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Leave only versions greater than current
|
// Leave only versions greater than current
|
||||||
let filteredVersions = versions.filter(version =>
|
let filteredVersions = versions.filter(version =>
|
||||||
isGreaterThan(version, fromVersion)
|
isGreaterThan(version, fromVersion)
|
||||||
);
|
);
|
||||||
filteredVersions = filterUnstable(
|
|
||||||
ignoreUnstable,
|
// Return all versions if we aren't ignore unstable. Also ignore latest
|
||||||
fromVersion,
|
if (ignoreUnstable === false) {
|
||||||
filteredVersions
|
return filteredVersions;
|
||||||
);
|
}
|
||||||
filteredVersions = filterLatest(
|
|
||||||
|
// if current is unstable then allow unstable in the current major only
|
||||||
|
if (!isStable(fromVersion)) {
|
||||||
|
// Allow unstable only in current major
|
||||||
|
return filteredVersions.filter(
|
||||||
|
version =>
|
||||||
|
isStable(version) || getMajor(version) === getMajor(fromVersion)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normal case: remove all unstable
|
||||||
|
filteredVersions = filteredVersions.filter(isStable);
|
||||||
|
|
||||||
|
return filterLatest(
|
||||||
respectLatest,
|
respectLatest,
|
||||||
fromVersion,
|
fromVersion,
|
||||||
latestVersion,
|
latestVersion,
|
||||||
filteredVersions
|
filteredVersions
|
||||||
);
|
);
|
||||||
return filteredVersions;
|
|
||||||
}
|
|
||||||
|
|
||||||
function filterUnstable(ignoreUnstable, fromVersion, versions) {
|
|
||||||
// Filter nothing out if we are not ignoring unstable
|
|
||||||
if (ignoreUnstable === false) {
|
|
||||||
return versions;
|
|
||||||
}
|
|
||||||
// Filter out all unstable if fromVersion is stable
|
|
||||||
if (isStable(fromVersion)) {
|
|
||||||
// Remove all unstable
|
|
||||||
return versions.filter(isStable);
|
|
||||||
}
|
|
||||||
// Allow unstable only in current major
|
|
||||||
return versions.filter(
|
|
||||||
version => isStable(version) || getMajor(version) === getMajor(fromVersion)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterLatest(respectLatest, fromVersion, latestVersion, versions) {
|
function filterLatest(respectLatest, fromVersion, latestVersion, versions) {
|
||||||
// No filtering if no latest
|
// No filtering if no latest
|
||||||
|
// istanbul ignore if
|
||||||
if (!latestVersion) {
|
if (!latestVersion) {
|
||||||
return versions;
|
return versions;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue