From 1ed10fbe4b84e11b02fd73e5efda6092ab5092ec Mon Sep 17 00:00:00 2001
From: Tobias Bieniek <tobias@bieniek.cloud>
Date: Sat, 12 Sep 2020 14:10:19 +0200
Subject: [PATCH] feat(datasource/crate): Assign `dependencyUrl` property
 (#7261)

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.
---
 lib/datasource/crate/__snapshots__/index.spec.ts.snap | 2 ++
 lib/datasource/crate/index.ts                         | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/lib/datasource/crate/__snapshots__/index.spec.ts.snap b/lib/datasource/crate/__snapshots__/index.spec.ts.snap
index b16d093225..12358777c1 100644
--- a/lib/datasource/crate/__snapshots__/index.spec.ts.snap
+++ b/lib/datasource/crate/__snapshots__/index.spec.ts.snap
@@ -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",
@@ -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",
diff --git a/lib/datasource/crate/index.ts b/lib/datasource/crate/index.ts
index 324dad6e00..9e52e7f79d 100644
--- a/lib/datasource/crate/index.ts
+++ b/lib/datasource/crate/index.ts
@@ -38,6 +38,7 @@ 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
@@ -45,6 +46,7 @@ export async function getReleases({
       .filter((line) => line.length !== 0) // remove empty lines
       .map((line) => JSON.parse(line)); // parse
     const result: ReleaseResult = {
+      dependencyUrl,
       releases: [],
     };
     result.releases = lines
-- 
GitLab