Skip to content

Clean up fallback to unstable version when looking for unyanked versions #2091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions app/routes/crate/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,19 @@ export default Route.extend({
.then(versions => {
const latestStableVersion = versions.find(version => {
// Find the latest version that is stable AND not-yanked.
if (!isUnstableVersion(version.get('num')) && !version.get('yanked')) {
return version;
}
return !isUnstableVersion(version.get('num')) && !version.get('yanked');
});

if (latestStableVersion == null) {
// Cannot find any version that is stable AND not-yanked.
// The fact that "maxVersion" itself cannot be found means that
// we have to fall back to the latest one that is unstable....
const latestUnyankedVersion = versions.find(version => {
// Find the latest version that is stable AND not-yanked.
if (!version.get('yanked')) {
return version;
}
// Find the latest version that is not-yanked.
return !version.get('yanked');
});

if (latestStableVersion == null) {
if (latestUnyankedVersion == null) {
// There's not even any unyanked version...
params.version_num = maxVersion;
} else {
Expand Down