mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-31 09:41:46 +00:00
ff6761ed23
* fix(config/global): return default values for `GlobalConfig.get` As noted in #39949, it can be awkward working with in `GlobalConfig.get`, where we would previously need to specify the default value when calling `.get`, which could lead to drift with the defaults for a given config option. To reduce this risk, we can rely on a given `default` for a configuration option, providing that as a default. Because this now definitely returns a value that matches the config option, it now allows us to remove `!` assertions. * fixup! fix(config/global): return default values for `GlobalConfig.get` Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> * fixup! fix(config/global): return default values for `GlobalConfig.get` * test(presets): remove impossible test As it's now not possible to set a value as `undefined` (as `GlobalConfig` will then use the default), this test no longer validates anything. * test(workers/repository): add mock Now `platform` defaults to `github`, we need to mock out the call to fetch config. Co-authored-by: Claude Sonnet 4.6 <jamie.tanna+claude-code@mend.io> * test: coverage * test: coverage --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <jamie.tanna+claude-code@mend.io>
82 lines
2.8 KiB
TypeScript
82 lines
2.8 KiB
TypeScript
import { GlobalConfig } from '../../../config/global.ts';
|
|
import { applySecretsAndVariablesToConfig } from '../../../config/secrets.ts';
|
|
import type { RenovateConfig } from '../../../config/types.ts';
|
|
import { logger } from '../../../logger/index.ts';
|
|
import { setRepositoryLogLevelRemaps } from '../../../logger/remap.ts';
|
|
import { platform } from '../../../modules/platform/index.ts';
|
|
import * as memCache from '../../../util/cache/memory/index.ts';
|
|
import { clone } from '../../../util/clone.ts';
|
|
import { cloneSubmodules, setUserRepoConfig } from '../../../util/git/index.ts';
|
|
import { getAll } from '../../../util/host-rules.ts';
|
|
import { initMutexes } from '../../../util/mutex.ts';
|
|
import { checkIfConfigured } from '../configured.ts';
|
|
import { PackageFiles } from '../package-files.ts';
|
|
import type { WorkerPlatformConfig } from './apis.ts';
|
|
import { initApis } from './apis.ts';
|
|
import { initializeCaches, resetCaches } from './cache.ts';
|
|
import { getRepoConfig } from './config.ts';
|
|
import { detectVulnerabilityAlerts } from './vulnerability.ts';
|
|
|
|
function initializeConfig(config: RenovateConfig): RenovateConfig {
|
|
return {
|
|
...clone(config),
|
|
errors: [],
|
|
warnings: [],
|
|
branchList: [],
|
|
};
|
|
}
|
|
|
|
function warnOnUnsupportedOptions(config: RenovateConfig): void {
|
|
if (config.filterUnavailableUsers && !platform.filterUnavailableUsers) {
|
|
const platform = GlobalConfig.get('platform');
|
|
logger.warn(
|
|
{ platform },
|
|
`Configuration option 'filterUnavailableUsers' is not supported on the current platform.`,
|
|
);
|
|
}
|
|
|
|
if (config.expandCodeOwnersGroups && !platform.expandGroupMembers) {
|
|
const platform = GlobalConfig.get('platform');
|
|
logger.warn(
|
|
{ platform },
|
|
`Configuration option 'expandCodeOwnersGroups' is not supported on the current platform.`,
|
|
);
|
|
}
|
|
}
|
|
|
|
export async function initRepo(
|
|
config_: RenovateConfig,
|
|
): Promise<RenovateConfig> {
|
|
PackageFiles.clear();
|
|
let config: RenovateConfig = initializeConfig(config_);
|
|
await resetCaches();
|
|
logger.once.reset();
|
|
memCache.init();
|
|
initMutexes();
|
|
config = await initApis(config);
|
|
await initializeCaches(config as WorkerPlatformConfig);
|
|
config = await getRepoConfig(config);
|
|
setRepositoryLogLevelRemaps(config.logLevelRemap);
|
|
if (config.mode === 'silent') {
|
|
logger.info(
|
|
'Repository is running with mode=silent and will not make Issues or PRs by default',
|
|
);
|
|
}
|
|
checkIfConfigured(config);
|
|
warnOnUnsupportedOptions(config);
|
|
config = applySecretsAndVariablesToConfig({
|
|
config,
|
|
});
|
|
setUserRepoConfig(config);
|
|
config = await detectVulnerabilityAlerts(config);
|
|
// istanbul ignore if
|
|
if (config.printConfig) {
|
|
logger.info(
|
|
{ config, hostRules: getAll() },
|
|
'Full resolved config and hostRules including presets',
|
|
);
|
|
}
|
|
await cloneSubmodules(!!config.cloneSubmodules, config.cloneSubmodulesFilter);
|
|
return config;
|
|
}
|