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.
This commit is contained in:
Rhys Arkins 2022-10-05 15:46:05 +02:00
parent 43c3ea1acb
commit caad0ae28e
8 changed files with 25 additions and 38 deletions

View file

@ -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

View file

@ -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
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.
## forkToken
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.
You probably don't need this option - it is an experimental setting developed for the Forking Renovate hosted GitHub App.
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
Renovate will then create branches on the fork and opens Pull Requests on the parent repository.
## gitNoVerify

View file

@ -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',

View file

@ -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,

View file

@ -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();
});

View file

@ -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}`;

View file

@ -80,7 +80,6 @@ export interface LocalRepoConfig {
prReviewsRequired: boolean;
repoForceRebase?: boolean;
parentRepo: string | null;
forkMode?: boolean;
forkToken?: string;
prList: GhPr[] | null;
issueList: any[] | null;

View file

@ -37,7 +37,6 @@ export interface RepoParams {
repository: string;
endpoint?: string;
gitUrl?: GitUrlOption;
forkMode?: string;
forkToken?: string;
includeForks?: boolean;
renovateUsername?: string;