From cf4fcce8de7d01a3154fbcfa4326c8967d91d064 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Fri, 15 Jul 2022 16:34:31 +0300
Subject: [PATCH] fix(onboarding): use default preset only if truthy (#16596)

Closes #16526
---
 .../repository/onboarding/branch/config.ts    | 21 ++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/lib/workers/repository/onboarding/branch/config.ts b/lib/workers/repository/onboarding/branch/config.ts
index 1aa01c1fd4..f8ce71c504 100644
--- a/lib/workers/repository/onboarding/branch/config.ts
+++ b/lib/workers/repository/onboarding/branch/config.ts
@@ -26,8 +26,9 @@ async function getOnboardingConfig(
   // Check for org/renovate-config
   try {
     const repo = `${orgName}/renovate-config`;
-    await getPreset({ repo });
-    orgPreset = `local>${repo}`;
+    if (await getPreset({ repo })) {
+      orgPreset = `local>${repo}`;
+    }
   } catch (err) {
     if (
       err.message !== PRESET_DEP_NOT_FOUND &&
@@ -43,11 +44,14 @@ async function getOnboardingConfig(
     try {
       const repo = `${orgName}/.${platform}`;
       const presetName = 'renovate-config';
-      await getPreset({
-        repo,
-        presetName,
-      });
-      orgPreset = `local>${repo}:${presetName}`;
+      if (
+        await getPreset({
+          repo,
+          presetName,
+        })
+      ) {
+        orgPreset = `local>${repo}:${presetName}`;
+      }
     } catch (err) {
       if (
         err.message !== PRESET_DEP_NOT_FOUND &&
@@ -59,6 +63,9 @@ async function getOnboardingConfig(
   }
 
   if (orgPreset) {
+    logger.debug(
+      `Found org preset ${orgPreset} - using it in onboarding config`
+    );
     onboardingConfig = {
       $schema: 'https://docs.renovatebot.com/renovate-schema.json',
       extends: [orgPreset],
-- 
GitLab