From 766d92144f5fb0c605e9b639778850902623d9d6 Mon Sep 17 00:00:00 2001
From: Jamie Magee <jamie.magee@gmail.com>
Date: Sat, 12 Feb 2022 21:39:15 -0800
Subject: [PATCH] refactor(conan): retrieve raw content directly from GitHub
 (#14195)

---
 lib/datasource/conan/__fixtures__/poco.yaml    | 15 +++++++++++++++
 .../conan/__fixtures__/poco.yaml.json          | 18 ------------------
 lib/datasource/conan/index.spec.ts             |  2 +-
 lib/datasource/conan/index.ts                  |  7 ++++---
 4 files changed, 20 insertions(+), 22 deletions(-)
 create mode 100644 lib/datasource/conan/__fixtures__/poco.yaml
 delete mode 100644 lib/datasource/conan/__fixtures__/poco.yaml.json

diff --git a/lib/datasource/conan/__fixtures__/poco.yaml b/lib/datasource/conan/__fixtures__/poco.yaml
new file mode 100644
index 0000000000..9ae83182c9
--- /dev/null
+++ b/lib/datasource/conan/__fixtures__/poco.yaml
@@ -0,0 +1,15 @@
+versions:
+  "1.11.1":
+    folder: all
+  "1.11.0":
+    folder: all
+  "1.10.1":
+    folder: all
+  "1.10.0":
+    folder: all
+  "1.9.3":
+    folder: all
+  "1.9.4":
+    folder: all
+  "1.8.1":
+    folder: all
\ No newline at end of file
diff --git a/lib/datasource/conan/__fixtures__/poco.yaml.json b/lib/datasource/conan/__fixtures__/poco.yaml.json
deleted file mode 100644
index 9b2336d5d2..0000000000
--- a/lib/datasource/conan/__fixtures__/poco.yaml.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
-  "name": "config.yml",
-  "path": "recipes/poco/config.yml",
-  "sha": "ade8cc1fda69a36ad5a23ad903a4b76223393ca2",
-  "size": 203,
-  "url": "https://api.github.com/repos/conan-io/conan-center-index/contents/recipes/poco/config.yml?ref=master",
-  "html_url": "https://github.com/conan-io/conan-center-index/blob/master/recipes/poco/config.yml",
-  "git_url": "https://api.github.com/repos/conan-io/conan-center-index/git/blobs/ade8cc1fda69a36ad5a23ad903a4b76223393ca2",
-  "download_url": "https://raw.githubusercontent.com/conan-io/conan-center-index/master/recipes/poco/config.yml",
-  "type": "file",
-  "content": "dmVyc2lvbnM6CiAgIjEuMTEuMSI6CiAgICBmb2xkZXI6IGFsbAogICIxLjEx\nLjAiOgogICAgZm9sZGVyOiBhbGwKICAiMS4xMC4xIjoKICAgIGZvbGRlcjog\nYWxsCiAgIjEuMTAuMCI6CiAgICBmb2xkZXI6IGFsbAogICIxLjkuMyI6CiAg\nICBmb2xkZXI6IGFsbAogICIxLjkuNCI6CiAgICBmb2xkZXI6IGFsbAogICIx\nLjguMSI6CiAgICBmb2xkZXI6IGFsbAo=\n",
-  "encoding": "base64",
-  "_links": {
-    "self": "https://api.github.com/repos/conan-io/conan-center-index/contents/recipes/poco/config.yml?ref=master",
-    "git": "https://api.github.com/repos/conan-io/conan-center-index/git/blobs/ade8cc1fda69a36ad5a23ad903a4b76223393ca2",
-    "html": "https://github.com/conan-io/conan-center-index/blob/master/recipes/poco/config.yml"
-  }
-}
diff --git a/lib/datasource/conan/index.spec.ts b/lib/datasource/conan/index.spec.ts
index 6b917705e0..756a936516 100644
--- a/lib/datasource/conan/index.spec.ts
+++ b/lib/datasource/conan/index.spec.ts
@@ -7,7 +7,7 @@ import { defaultRegistryUrl } from './common';
 import { ConanDatasource } from '.';
 
 const pocoJson = Fixtures.get('poco.json');
-const pocoYamlGitHubContent = Fixtures.get('poco.yaml.json');
+const pocoYamlGitHubContent = Fixtures.get('poco.yaml');
 const malformedJson = Fixtures.get('malformed.json');
 const fakeJson = Fixtures.get('fake.json');
 const datasource = ConanDatasource.id;
diff --git a/lib/datasource/conan/index.ts b/lib/datasource/conan/index.ts
index e2286f5739..abb62555e0 100644
--- a/lib/datasource/conan/index.ts
+++ b/lib/datasource/conan/index.ts
@@ -37,9 +37,10 @@ export class ConanDatasource extends Datasource {
       return null;
     }
     const url = `https://api.github.com/repos/conan-io/conan-center-index/contents/recipes/${depName}/config.yml`;
-    const res = await this.githubHttp.getJson<{ content: string }>(url);
-    const content = Buffer.from(res.body.content, 'base64').toString('utf8');
-    const doc = load(content, {
+    const res = await this.githubHttp.get(url, {
+      headers: { Accept: 'application/vnd.github.v3.raw' },
+    });
+    const doc = load(res.body, {
       json: true,
     }) as ConanYAML;
     return {
-- 
GitLab