Skip to content

Commit

Permalink
feat(datasource/crate): Assign dependencyUrl property (#7261)
Browse files Browse the repository at this point in the history
If I understand correctly the `dependencyUrl` property is supposed to link to the package on the package registry, which is crates.io in this case. This could potentially be used in the PR description if no homepage or source URL is available.
  • Loading branch information
Turbo87 committed Sep 12, 2020
1 parent e872011 commit 1ed10fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/datasource/crate/__snapshots__/index.spec.ts.snap
Expand Up @@ -2,6 +2,7 @@

exports[`datasource/crate getReleases processes real data: amethyst 1`] = `
Object {
"dependencyUrl": "https://crates.io/crates/amethyst",
"releases": Array [
Object {
"version": "0.1.0",
Expand Down Expand Up @@ -144,6 +145,7 @@ Array [

exports[`datasource/crate getReleases processes real data: libc 1`] = `
Object {
"dependencyUrl": "https://crates.io/crates/libc",
"releases": Array [
Object {
"version": "0.1.0",
Expand Down
2 changes: 2 additions & 0 deletions lib/datasource/crate/index.ts
Expand Up @@ -38,13 +38,15 @@ export async function getReleases({
const baseUrl =
'https://raw.githubusercontent.com/rust-lang/crates.io-index/master/';
const crateUrl = baseUrl + path;
const dependencyUrl = `https://crates.io/crates/${lookupName}`;
try {
const lines = (await http.get(crateUrl)).body
.split('\n') // break into lines
.map((line) => line.trim()) // remove whitespace
.filter((line) => line.length !== 0) // remove empty lines
.map((line) => JSON.parse(line)); // parse
const result: ReleaseResult = {
dependencyUrl,
releases: [],
};
result.releases = lines
Expand Down

0 comments on commit 1ed10fb

Please sign in to comment.