diff --git a/lib/workers/repository/onboarding/branch/index.spec.ts b/lib/workers/repository/onboarding/branch/index.spec.ts index 877aa6e42607cba4d78d28eaf7bb451d26872088..d7a472e6cfa1e5ddfd16e29a646d3e7f88fea087 100644 --- a/lib/workers/repository/onboarding/branch/index.spec.ts +++ b/lib/workers/repository/onboarding/branch/index.spec.ts @@ -11,6 +11,7 @@ import { configFileNames } from '../../../../config/app-strings'; import { getConfig } from '../../../../config/defaults'; import { GlobalConfig } from '../../../../config/global'; import { + REPOSITORY_DISABLED_BY_CONFIG, REPOSITORY_FORKED, REPOSITORY_NO_PACKAGE_FILES, } from '../../../../constants/error-messages'; @@ -72,6 +73,13 @@ describe('workers/repository/onboarding/branch/index', () => { ); }); + it('throws if bot disabled', async () => { + config.enabled = false; + await expect(checkOnboardingBranch(config)).rejects.toThrow( + REPOSITORY_DISABLED_BY_CONFIG, + ); + }); + it.each` checkboxEnabled | expected ${true} | ${true} diff --git a/lib/workers/repository/onboarding/branch/index.ts b/lib/workers/repository/onboarding/branch/index.ts index 5090b9c847f11893bfa9f6dd5201dfcf5e0e7e8e..bc8645cfbcc676d56f5740ee8ff556b080eba727 100644 --- a/lib/workers/repository/onboarding/branch/index.ts +++ b/lib/workers/repository/onboarding/branch/index.ts @@ -2,15 +2,13 @@ import is from '@sindresorhus/is'; import { mergeChildConfig } from '../../../../config'; import { GlobalConfig } from '../../../../config/global'; import type { RenovateConfig } from '../../../../config/types'; -import { - REPOSITORY_FORKED, - REPOSITORY_NO_PACKAGE_FILES, -} from '../../../../constants/error-messages'; +import { REPOSITORY_NO_PACKAGE_FILES } from '../../../../constants/error-messages'; import { logger } from '../../../../logger'; import { type Pr, platform } from '../../../../modules/platform'; import { scm } from '../../../../modules/platform/scm'; import { getCache } from '../../../../util/cache/repository'; import { getBranchCommit, setGitAuthor } from '../../../../util/git'; +import { checkIfConfigured } from '../../configured'; import { extractAllDependencies } from '../../extract'; import { mergeRenovateConfig } from '../../init/merge'; import { OnboardingState } from '../common'; @@ -43,9 +41,8 @@ export async function checkOnboardingBranch( deleteOnboardingCache(); return { ...config, repoIsOnboarded }; } - if (config.isFork && config.forkProcessing !== 'enabled') { - throw new Error(REPOSITORY_FORKED); - } + checkIfConfigured(config); + logger.debug('Repo is not onboarded'); // global gitAuthor will need to be used setGitAuthor(config.gitAuthor);