Skip to content

Commit

Permalink
feat(github)!: remove forkMode setting (#18074)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rarkins committed Oct 23, 2022
1 parent 43c3ea1 commit caad0ae
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 37 deletions.
3 changes: 2 additions & 1 deletion docs/usage/configuration-options.md
Expand Up @@ -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

Expand Down
13 changes: 6 additions & 7 deletions docs/usage/self-hosted-configuration.md
Expand Up @@ -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
Expand Down
15 changes: 3 additions & 12 deletions lib/config/options/index.ts
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/platform/github/__snapshots__/index.spec.ts.snap
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions lib/modules/platform/github/index.spec.ts
Expand Up @@ -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();
});
Expand All @@ -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();
});
Expand Down
14 changes: 6 additions & 8 deletions lib/modules/platform/github/index.ts
Expand Up @@ -246,7 +246,6 @@ export async function getJsonFile(
export async function initRepo({
endpoint,
repository,
forkMode,
forkToken,
renovateUsername,
cloneSubmodules,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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}`;
Expand Down
1 change: 0 additions & 1 deletion lib/modules/platform/github/types.ts
Expand Up @@ -80,7 +80,6 @@ export interface LocalRepoConfig {
prReviewsRequired: boolean;
repoForceRebase?: boolean;
parentRepo: string | null;
forkMode?: boolean;
forkToken?: string;
prList: GhPr[] | null;
issueList: any[] | null;
Expand Down
1 change: 0 additions & 1 deletion lib/modules/platform/types.ts
Expand Up @@ -37,7 +37,6 @@ export interface RepoParams {
repository: string;
endpoint?: string;
gitUrl?: GitUrlOption;
forkMode?: string;
forkToken?: string;
includeForks?: boolean;
renovateUsername?: string;
Expand Down

0 comments on commit caad0ae

Please sign in to comment.