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 = {
|
||||
filterVersions,
|
||||
filterUnstable,
|
||||
filterLatest,
|
||||
};
|
||||
|
||||
|
@ -15,42 +14,40 @@ function filterVersions(config, fromVersion, latestVersion, versions) {
|
|||
if (!fromVersion) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Leave only versions greater than current
|
||||
let filteredVersions = versions.filter(version =>
|
||||
isGreaterThan(version, fromVersion)
|
||||
);
|
||||
filteredVersions = filterUnstable(
|
||||
ignoreUnstable,
|
||||
fromVersion,
|
||||
filteredVersions
|
||||
|
||||
// Return all versions if we aren't ignore unstable. Also ignore latest
|
||||
if (ignoreUnstable === false) {
|
||||
return filteredVersions;
|
||||
}
|
||||
|
||||
// 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)
|
||||
);
|
||||
filteredVersions = filterLatest(
|
||||
}
|
||||
|
||||
// Normal case: remove all unstable
|
||||
filteredVersions = filteredVersions.filter(isStable);
|
||||
|
||||
return filterLatest(
|
||||
respectLatest,
|
||||
fromVersion,
|
||||
latestVersion,
|
||||
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) {
|
||||
// No filtering if no latest
|
||||
// istanbul ignore if
|
||||
if (!latestVersion) {
|
||||
return versions;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue