From 58784fc958b4b4a216d31f11b54f635d9ad2bd74 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@keylocation.sg>
Date: Wed, 1 Nov 2017 11:53:18 +0100
Subject: [PATCH] feat: add renovateFork option

99% of the time we should not Renovate forked repositories. Previously, we skipped onboarding them unless a renovate.json was present. However, that meant that if someone forked a repository where the source was using Renovate, then the fork gets renovated automatically too. After this change, forked repositories need to set renovateFork=true in their renovate.json

Closes #940

BREAKING CHANGE: Forked repositories now need to configure renovateFork=true in renovate.json
---
 docs/configuration.md                 | 8 ++++++++
 lib/config/definitions.js             | 7 +++++++
 lib/workers/repository/index.js       | 2 +-
 test/workers/repository/index.spec.js | 2 +-
 4 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/docs/configuration.md b/docs/configuration.md
index b72308fb25..7c460f40bf 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -154,6 +154,14 @@ Obviously, you can't set repository or package file location with this method.
   <td>`RENOVATE_ONBOARDING`</td>
   <td>`--onboarding`<td>
 </tr>
+<tr>
+  <td>`renovateFork`</td>
+  <td>Whether to renovate a forked repository or not.</td>
+  <td>boolean</td>
+  <td><pre>false</pre></td>
+  <td>`RENOVATE_RENOVATE_FORK`</td>
+  <td>`--renovate-fork`<td>
+</tr>
 <tr>
   <td>`privateKey`</td>
   <td>Server-side private key</td>
diff --git a/lib/config/definitions.js b/lib/config/definitions.js
index 7a8e188772..c128f35a02 100644
--- a/lib/config/definitions.js
+++ b/lib/config/definitions.js
@@ -71,6 +71,13 @@ const options = [
     stage: 'repository',
     type: 'boolean',
   },
+  {
+    name: 'renovateFork',
+    description: 'Whether to renovate a forked repository or not.',
+    stage: 'repository',
+    type: 'boolean',
+    default: false,
+  },
   // encryption
   {
     name: 'privateKey',
diff --git a/lib/workers/repository/index.js b/lib/workers/repository/index.js
index a2b003e656..7000cd3b83 100644
--- a/lib/workers/repository/index.js
+++ b/lib/workers/repository/index.js
@@ -48,7 +48,7 @@ async function renovateRepository(repoConfig, token) {
       return null;
     }
     if (config.isFork) {
-      if (config.renovateJsonPresent) {
+      if (config.renovateFork) {
         logger.info('Processing forked repository');
       } else {
         logger.debug('repository is a fork and not manually configured');
diff --git a/test/workers/repository/index.spec.js b/test/workers/repository/index.spec.js
index 3f1e87bae3..abb83c9b69 100644
--- a/test/workers/repository/index.spec.js
+++ b/test/workers/repository/index.spec.js
@@ -78,7 +78,7 @@ describe('workers/repository', () => {
     });
     it('does not skip repository if its a configured fork', async () => {
       config.isFork = true;
-      config.renovateJsonPresent = true;
+      config.renovateFork = true;
       manager.detectPackageFiles.mockImplementationOnce(input => ({
         ...input,
         ...{ packageFiles: [] },
-- 
GitLab