Skip to content
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

feat(rubygems): fallback to info when version fails #7323

Merged
merged 14 commits into from Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 40 additions & 16 deletions lib/datasource/rubygems/get.ts
Expand Up @@ -50,23 +50,47 @@ export async function getDependency(
return null;
}

const versions = (await fetch(dependency, registry, VERSIONS_PATH)) || [];
let versions = [];
let releases = [];
try {
versions = await fetch(dependency, registry, VERSIONS_PATH);
} catch (err) {
rarkins marked this conversation as resolved.
Show resolved Hide resolved
if (err.statusCode === 400 || err.statusCode === 404) {
logger.debug({ registry }, 'version endpoint errors or is not available');
logger.debug({ err });
henrysachs marked this conversation as resolved.
Show resolved Hide resolved
} else {
throw err;
}
}

const releases = versions.map(
({
number: version,
platform: rubyPlatform,
created_at: releaseTimestamp,
rubygems_version: rubygemsVersion,
ruby_version: rubyVersion,
}) => ({
version,
rubyPlatform,
releaseTimestamp,
rubygemsVersion,
rubyVersion,
})
);
if (versions.length === 0 && info.version) {
logger.warn('falling back to the version from the info endpoint');
releases = [
{
version: info.version,
rubyPlatform: info.platform,
releaseTimestamp: null,
rubyVersion: null,
rubygemsVersion: '\u003e= 0',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the meaning of this value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was the default value from the versions endpoint its basically >= 0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but we can remove it I just wanted to match the signature from the "default" case

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, remove it

},
];
} else {
releases = versions.map(
({
number: version,
platform: rubyPlatform,
created_at: releaseTimestamp,
rubygems_version: rubygemsVersion,
ruby_version: rubyVersion,
}) => ({
version,
rubyPlatform,
releaseTimestamp,
rubygemsVersion,
rubyVersion,
})
);
}

return {
releases,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -96,7 +96,8 @@
"Viral Ruparel <viralruparel@gmail.com>",
"Vladimir Starkov <iamstarkov@gmail.com>",
"Mikhail Yakushin <driver733@gmail.com>",
"Sebastian Poxhofer <sebastian@poxhofer.at>"
"Sebastian Poxhofer <sebastian@poxhofer.at>",
"Henry Sachs <henrysachs@gmail.com>"
],
"license": "AGPL-3.0",
"bugs": {
Expand Down