From caad0ae28e0a9e0360fde20d2e8a37a3cf1e549e Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Wed, 5 Oct 2022 15:46:05 +0200 Subject: [PATCH] feat(github)!: remove forkMode setting (#18074) Removes forkMode setting and instead relies on forkToken alone to indicate forking mode is active. Additionally, defines forkToken as an experimental setting. BREAKING CHANGE: No longer necessary to configure forkMode. Forking mode is now experimental. --- docs/usage/configuration-options.md | 3 ++- docs/usage/self-hosted-configuration.md | 13 ++++++------- lib/config/options/index.ts | 15 +++------------ .../github/__snapshots__/index.spec.ts.snap | 4 ++-- lib/modules/platform/github/index.spec.ts | 10 +++++----- lib/modules/platform/github/index.ts | 14 ++++++-------- lib/modules/platform/github/types.ts | 1 - lib/modules/platform/types.ts | 1 - 8 files changed, 24 insertions(+), 37 deletions(-) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index 9a0ae7703d..123d305747 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -249,7 +249,8 @@ If so then Renovate will reflect this setting in its description and use package <!-- prettier-ignore --> !!! note - The `baseBranches` config option is not supported when `forkMode` is enabled, including in the Forking Renovate app. + Do _not_ use the `baseBranches` config option when you've set a `forkToken`. + You may need a `forkToken` when you're using the Forking Renovate app. ## bbUseDefaultReviewers diff --git a/docs/usage/self-hosted-configuration.md b/docs/usage/self-hosted-configuration.md index 32f562c246..3873769761 100644 --- a/docs/usage/self-hosted-configuration.md +++ b/docs/usage/self-hosted-configuration.md @@ -376,16 +376,15 @@ In practice, it is implemented by converting the `force` configuration into a `p This is set to `true` by default, meaning that any settings (such as `schedule`) take maximum priority even against custom settings existing inside individual repositories. It will also override any settings in `packageRules`. -## forkMode +## forkToken -You probably have no need for this option - it is an experimental setting for the Renovate hosted GitHub App. -If this is set to `true` then Renovate will fork the repository into the personal space of the person owning the Personal Access Token. +You probably don't need this option - it is an experimental setting developed for the Forking Renovate hosted GitHub App. -## forkToken +If this value is configured then Renovate: + +- forks the target repository into the account that owns the PAT +- keep this fork's default branch up-to-date with the target -You probably don't need this option - it is an experimental setting for the Renovate hosted GitHub App. -This should be set to a Personal Access Token (GitHub only) when `forkMode` is set to `true`. -Renovate will use this token to fork the repository into the personal space of the person owning the Personal Access Token. Renovate will then create branches on the fork and opens Pull Requests on the parent repository. ## gitNoVerify diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index 4f39e98cf1..8b0221ad6f 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -409,23 +409,14 @@ const options: RenovateOptions[] = [ type: 'boolean', default: false, }, - { - name: 'forkMode', - description: - 'Set to `true` to fork the source repository and create branches there instead.', - stage: 'repository', - type: 'boolean', - default: false, - globalOnly: true, - }, { name: 'forkToken', - description: - 'Will be used on GitHub when `forkMode` is set to `true` to clone the repositories.', + description: 'Set a personal access token here to enable "fork mode".', stage: 'repository', type: 'string', - default: '', globalOnly: true, + supportedPlatforms: ['github'], + experimental: true, }, { name: 'githubTokenWarn', diff --git a/lib/modules/platform/github/__snapshots__/index.spec.ts.snap b/lib/modules/platform/github/__snapshots__/index.spec.ts.snap index 2289cddf8c..8dbafeab11 100644 --- a/lib/modules/platform/github/__snapshots__/index.spec.ts.snap +++ b/lib/modules/platform/github/__snapshots__/index.spec.ts.snap @@ -71,7 +71,7 @@ exports[`modules/platform/github/index initRepo detects fork default branch mism } `; -exports[`modules/platform/github/index initRepo should fork when forkMode 1`] = ` +exports[`modules/platform/github/index initRepo should fork when using forkToken 1`] = ` { "defaultBranch": "master", "isFork": false, @@ -111,7 +111,7 @@ exports[`modules/platform/github/index initRepo should squash 1`] = ` } `; -exports[`modules/platform/github/index initRepo should update fork when forkMode 1`] = ` +exports[`modules/platform/github/index initRepo should update fork when using forkToken 1`] = ` { "defaultBranch": "master", "isFork": false, diff --git a/lib/modules/platform/github/index.spec.ts b/lib/modules/platform/github/index.spec.ts index a4d5ea579d..211719a4df 100644 --- a/lib/modules/platform/github/index.spec.ts +++ b/lib/modules/platform/github/index.spec.ts @@ -313,23 +313,23 @@ describe('modules/platform/github/index', () => { expect(config).toMatchSnapshot(); }); - it('should fork when forkMode', async () => { + it('should fork when using forkToken', async () => { const scope = httpMock.scope(githubApiHost); forkInitRepoMock(scope, 'some/repo', false); const config = await github.initRepo({ repository: 'some/repo', - forkMode: 'true', + forkToken: 'true', }); expect(config).toMatchSnapshot(); }); - it('should update fork when forkMode', async () => { + it('should update fork when using forkToken', async () => { const scope = httpMock.scope(githubApiHost); forkInitRepoMock(scope, 'some/repo', true); scope.patch('/repos/forked/repo/git/refs/heads/master').reply(200); const config = await github.initRepo({ repository: 'some/repo', - forkMode: 'true', + forkToken: 'true', }); expect(config).toMatchSnapshot(); }); @@ -342,7 +342,7 @@ describe('modules/platform/github/index', () => { scope.patch('/repos/forked/repo/git/refs/heads/master').reply(200); const config = await github.initRepo({ repository: 'some/repo', - forkMode: 'true', + forkToken: 'true', }); expect(config).toMatchSnapshot(); }); diff --git a/lib/modules/platform/github/index.ts b/lib/modules/platform/github/index.ts index 8f448afa89..2d4f3d6460 100644 --- a/lib/modules/platform/github/index.ts +++ b/lib/modules/platform/github/index.ts @@ -246,7 +246,6 @@ export async function getJsonFile( export async function initRepo({ endpoint, repository, - forkMode, forkToken, renovateUsername, cloneSubmodules, @@ -371,9 +370,8 @@ export async function initRepo({ config.issueList = null; config.prList = null; - config.forkMode = !!forkMode; - if (forkMode) { - logger.debug('Bot is in forkMode'); + if (forkToken) { + logger.debug('Bot is in fork mode'); config.forkToken = forkToken; // save parent name then delete config.parentRepo = config.repository; @@ -489,7 +487,7 @@ export async function initRepo({ const parsedEndpoint = URL.parse(platformConfig.endpoint); // istanbul ignore else - if (forkMode) { + if (forkToken) { logger.debug('Using forkToken for git init'); parsedEndpoint.auth = config.forkToken ?? null; } else { @@ -624,7 +622,7 @@ export async function getPrList(): Promise<GhPr[]> { if (!config.prList) { const repo = config.parentRepo ?? config.repository; const username = - !config.forkMode && !config.ignorePrAuthor && config.renovateUsername + !config.forkToken && !config.ignorePrAuthor && config.renovateUsername ? config.renovateUsername : null; // TODO: check null `repo` (#7154) @@ -657,7 +655,7 @@ export async function findPr({ return false; } - if (!config.forkMode && config.repository !== p.sourceRepo) { + if (!config.forkToken && config.repository !== p.sourceRepo) { return false; } @@ -1415,7 +1413,7 @@ export async function createPr({ }: CreatePRConfig): Promise<GhPr | null> { const body = sanitize(rawBody); const base = targetBranch; - // Include the repository owner to handle forkMode and regular mode + // Include the repository owner to handle forkToken and regular mode // TODO: can `repository` be null? (#7154) const head = `${config.repository!.split('/')[0]}:${sourceBranch}`; diff --git a/lib/modules/platform/github/types.ts b/lib/modules/platform/github/types.ts index 11e56db517..2e3f3839b9 100644 --- a/lib/modules/platform/github/types.ts +++ b/lib/modules/platform/github/types.ts @@ -80,7 +80,6 @@ export interface LocalRepoConfig { prReviewsRequired: boolean; repoForceRebase?: boolean; parentRepo: string | null; - forkMode?: boolean; forkToken?: string; prList: GhPr[] | null; issueList: any[] | null; diff --git a/lib/modules/platform/types.ts b/lib/modules/platform/types.ts index 56a625eab0..d018ddaa56 100644 --- a/lib/modules/platform/types.ts +++ b/lib/modules/platform/types.ts @@ -37,7 +37,6 @@ export interface RepoParams { repository: string; endpoint?: string; gitUrl?: GitUrlOption; - forkMode?: string; forkToken?: string; includeForks?: boolean; renovateUsername?: string; -- GitLab