Skip to content

Commit

Permalink
refactor: move onboading repo lookup into dedicated function (#30554)
Browse files Browse the repository at this point in the history
Signed-off-by: LukasAuerbeck <17929465+LukasAuerbeck@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
  • Loading branch information
LukasAuerbeck and viceice committed Aug 2, 2024
1 parent de48a2b commit f0c2067
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions lib/workers/repository/onboarding/branch/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,33 @@ async function getOnboardingConfig(
): Promise<RenovateSharedConfig | undefined> {
let onboardingConfig = clone(config.onboardingConfig);

let foundPreset: string | undefined;
// TODO #22198 fix types
const foundPreset = await searchDefaultOnboardingPreset(config.repository!);

if (foundPreset) {
logger.debug(`Found preset ${foundPreset} - using it in onboarding config`);
onboardingConfig = {
$schema: 'https://docs.renovatebot.com/renovate-schema.json',
extends: [foundPreset],
};
} else {
// Organization preset did not exist
logger.debug(
'No default org/owner preset found, so the default onboarding config will be used instead.',
);
}

logger.debug({ config: onboardingConfig }, 'onboarding config');
return onboardingConfig;
}

async function searchDefaultOnboardingPreset(
repository: string,
): Promise<string | undefined> {
let foundPreset: string | undefined;
logger.debug('Checking for a default Renovate preset which can be used.');

// TODO #22198
const repoPathParts = config.repository!.split('/');
const repoPathParts = repository.split('/');

for (
let index = repoPathParts.length - 1;
Expand Down Expand Up @@ -77,21 +98,7 @@ async function getOnboardingConfig(
}
}

if (foundPreset) {
logger.debug(`Found preset ${foundPreset} - using it in onboarding config`);
onboardingConfig = {
$schema: 'https://docs.renovatebot.com/renovate-schema.json',
extends: [foundPreset],
};
} else {
// Organization preset did not exist
logger.debug(
'No default org/owner preset found, so the default onboarding config will be used instead.',
);
}

logger.debug({ config: onboardingConfig }, 'onboarding config');
return onboardingConfig;
return foundPreset;
}

async function getOnboardingConfigContents(
Expand Down

0 comments on commit f0c2067

Please sign in to comment.