Skip to content

Commit f0c2067

Browse files
refactor: move onboading repo lookup into dedicated function (renovatebot#30554)
Signed-off-by: LukasAuerbeck <[email protected]> Co-authored-by: Michael Kriese <[email protected]>
1 parent de48a2b commit f0c2067

File tree

1 file changed

+25
-18
lines changed
  • lib/workers/repository/onboarding/branch

1 file changed

+25
-18
lines changed

lib/workers/repository/onboarding/branch/config.ts

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,33 @@ async function getOnboardingConfig(
1414
): Promise<RenovateSharedConfig | undefined> {
1515
let onboardingConfig = clone(config.onboardingConfig);
1616

17-
let foundPreset: string | undefined;
17+
// TODO #22198 fix types
18+
const foundPreset = await searchDefaultOnboardingPreset(config.repository!);
19+
20+
if (foundPreset) {
21+
logger.debug(`Found preset ${foundPreset} - using it in onboarding config`);
22+
onboardingConfig = {
23+
$schema: 'https://docs.renovatebot.com/renovate-schema.json',
24+
extends: [foundPreset],
25+
};
26+
} else {
27+
// Organization preset did not exist
28+
logger.debug(
29+
'No default org/owner preset found, so the default onboarding config will be used instead.',
30+
);
31+
}
32+
33+
logger.debug({ config: onboardingConfig }, 'onboarding config');
34+
return onboardingConfig;
35+
}
1836

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

21-
// TODO #22198
22-
const repoPathParts = config.repository!.split('/');
43+
const repoPathParts = repository.split('/');
2344

2445
for (
2546
let index = repoPathParts.length - 1;
@@ -77,21 +98,7 @@ async function getOnboardingConfig(
7798
}
7899
}
79100

80-
if (foundPreset) {
81-
logger.debug(`Found preset ${foundPreset} - using it in onboarding config`);
82-
onboardingConfig = {
83-
$schema: 'https://docs.renovatebot.com/renovate-schema.json',
84-
extends: [foundPreset],
85-
};
86-
} else {
87-
// Organization preset did not exist
88-
logger.debug(
89-
'No default org/owner preset found, so the default onboarding config will be used instead.',
90-
);
91-
}
92-
93-
logger.debug({ config: onboardingConfig }, 'onboarding config');
94-
return onboardingConfig;
101+
return foundPreset;
95102
}
96103

97104
async function getOnboardingConfigContents(

0 commit comments

Comments
 (0)