From bb9e30f64a95d772421faa2483c6b9eab0f1c661 Mon Sep 17 00:00:00 2001
From: Jean-Michel Leclercq <jean.michel.lec@gmail.com>
Date: Mon, 19 Oct 2020 10:05:05 +0200
Subject: [PATCH] feat: New Configuration option fetchReleaseNotes (#7404)

---
 docs/usage/configuration-options.md           |  4 +++
 lib/config/common.ts                          |  2 ++
 lib/config/definitions.ts                     |  8 +++++
 .../repository/updates/branchify.spec.ts      | 34 +++++++++++++++++++
 lib/workers/repository/updates/branchify.ts   |  4 ++-
 5 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md
index 62954f7dff..faaed8762b 100644
--- a/docs/usage/configuration-options.md
+++ b/docs/usage/configuration-options.md
@@ -436,6 +436,10 @@ The above will change a raw version of `release-2.0.0` to `2.0.0`, for example.
 }
 ```
 
+## fetchReleaseNotes
+
+Configure this to `false` if you want to disable release notes fetching
+
 ## fileMatch
 
 `fileMatch` is used by Renovate to know which files in a repository to parse and extract, and it is possible to override defaults values to customize for your project's needs.
diff --git a/lib/config/common.ts b/lib/config/common.ts
index f91a223820..4bbee3aa5e 100644
--- a/lib/config/common.ts
+++ b/lib/config/common.ts
@@ -176,6 +176,8 @@ export interface RenovateConfig
   warnings?: ValidationMessage[];
   vulnerabilityAlerts?: RenovateSharedConfig;
   regexManagers?: CustomManager[];
+
+  fetchReleaseNotes?: boolean;
 }
 
 export interface AssigneesAndReviewersConfig {
diff --git a/lib/config/definitions.ts b/lib/config/definitions.ts
index 15655724b1..a4efd5a144 100644
--- a/lib/config/definitions.ts
+++ b/lib/config/definitions.ts
@@ -1836,6 +1836,14 @@ const options: RenovateOptions[] = [
     cli: false,
     env: false,
   },
+  {
+    name: 'fetchReleaseNotes',
+    description: 'Allow to disable release notes fetching',
+    type: 'boolean',
+    default: true,
+    cli: false,
+    env: false,
+  },
 ];
 
 export function getOptions(): RenovateOptions[] {
diff --git a/lib/workers/repository/updates/branchify.spec.ts b/lib/workers/repository/updates/branchify.spec.ts
index 717991de72..37ec326838 100644
--- a/lib/workers/repository/updates/branchify.spec.ts
+++ b/lib/workers/repository/updates/branchify.spec.ts
@@ -1,10 +1,14 @@
 import { RenovateConfig, mocked } from '../../../../test/util';
 import { getConfig } from '../../../config/defaults';
+import * as _changelog from '../changelog';
 import { branchifyUpgrades } from './branchify';
 import * as _flatten from './flatten';
 
 const flattenUpdates = mocked(_flatten).flattenUpdates;
+const embedChangelogs = mocked(_changelog).embedChangelogs;
+
 jest.mock('./flatten');
+jest.mock('../changelog');
 
 let config: RenovateConfig;
 beforeEach(() => {
@@ -113,5 +117,35 @@ describe('workers/repository/updates/branchify', () => {
       const res = await branchifyUpgrades(config, {});
       expect(Object.keys(res.branches)).toHaveLength(2);
     });
+    it('no fetch changelogs', async () => {
+      config.fetchReleaseNotes = false;
+      flattenUpdates.mockResolvedValueOnce([
+        {
+          depName: 'foo',
+          branchName: 'foo',
+          prTitle: 'some-title',
+          version: '1.1.0',
+          groupName: 'My Group',
+          group: { branchName: 'renovate/{{groupSlug}}' },
+        },
+        {
+          depName: 'foo',
+          branchName: 'foo',
+          prTitle: 'some-title',
+          version: '2.0.0',
+        },
+        {
+          depName: 'bar',
+          branchName: 'bar-{{version}}',
+          prTitle: 'some-title',
+          version: '1.1.0',
+          groupName: 'My Group',
+          group: { branchName: 'renovate/my-group' },
+        },
+      ]);
+      const res = await branchifyUpgrades(config, {});
+      expect(embedChangelogs).not.toHaveBeenCalled();
+      expect(Object.keys(res.branches)).toHaveLength(2);
+    });
   });
 });
diff --git a/lib/workers/repository/updates/branchify.ts b/lib/workers/repository/updates/branchify.ts
index e3f1630af5..7b69616479 100644
--- a/lib/workers/repository/updates/branchify.ts
+++ b/lib/workers/repository/updates/branchify.ts
@@ -37,7 +37,9 @@ export async function branchifyUpgrades(
     );
   }
   logger.debug(`Returning ${Object.keys(branchUpgrades).length} branch(es)`);
-  await embedChangelogs(branchUpgrades);
+  if (config.fetchReleaseNotes) {
+    await embedChangelogs(branchUpgrades);
+  }
   for (const branchName of Object.keys(branchUpgrades)) {
     // Add branch name to metadata before generating branch config
     addMeta({
-- 
GitLab