mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
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:
parent
43c3ea1acb
commit
caad0ae28e
8 changed files with 25 additions and 38 deletions
|
@ -249,7 +249,8 @@ If so then Renovate will reflect this setting in its description and use package
|
||||||
|
|
||||||
<!-- prettier-ignore -->
|
<!-- prettier-ignore -->
|
||||||
!!! note
|
!!! 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
|
## bbUseDefaultReviewers
|
||||||
|
|
||||||
|
|
|
@ -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.
|
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`.
|
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
|
## forkToken
|
||||||
|
|
||||||
You probably don't need this option - it is an experimental setting for the Renovate hosted GitHub App.
|
You probably don't need this option - it is an experimental setting developed for the Forking 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.
|
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.
|
Renovate will then create branches on the fork and opens Pull Requests on the parent repository.
|
||||||
|
|
||||||
## gitNoVerify
|
## gitNoVerify
|
||||||
|
|
|
@ -409,23 +409,14 @@ const options: RenovateOptions[] = [
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: false,
|
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',
|
name: 'forkToken',
|
||||||
description:
|
description: 'Set a personal access token here to enable "fork mode".',
|
||||||
'Will be used on GitHub when `forkMode` is set to `true` to clone the repositories.',
|
|
||||||
stage: 'repository',
|
stage: 'repository',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
|
||||||
globalOnly: true,
|
globalOnly: true,
|
||||||
|
supportedPlatforms: ['github'],
|
||||||
|
experimental: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'githubTokenWarn',
|
name: 'githubTokenWarn',
|
||||||
|
|
|
@ -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",
|
"defaultBranch": "master",
|
||||||
"isFork": false,
|
"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",
|
"defaultBranch": "master",
|
||||||
"isFork": false,
|
"isFork": false,
|
||||||
|
|
|
@ -313,23 +313,23 @@ describe('modules/platform/github/index', () => {
|
||||||
expect(config).toMatchSnapshot();
|
expect(config).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fork when forkMode', async () => {
|
it('should fork when using forkToken', async () => {
|
||||||
const scope = httpMock.scope(githubApiHost);
|
const scope = httpMock.scope(githubApiHost);
|
||||||
forkInitRepoMock(scope, 'some/repo', false);
|
forkInitRepoMock(scope, 'some/repo', false);
|
||||||
const config = await github.initRepo({
|
const config = await github.initRepo({
|
||||||
repository: 'some/repo',
|
repository: 'some/repo',
|
||||||
forkMode: 'true',
|
forkToken: 'true',
|
||||||
});
|
});
|
||||||
expect(config).toMatchSnapshot();
|
expect(config).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update fork when forkMode', async () => {
|
it('should update fork when using forkToken', async () => {
|
||||||
const scope = httpMock.scope(githubApiHost);
|
const scope = httpMock.scope(githubApiHost);
|
||||||
forkInitRepoMock(scope, 'some/repo', true);
|
forkInitRepoMock(scope, 'some/repo', true);
|
||||||
scope.patch('/repos/forked/repo/git/refs/heads/master').reply(200);
|
scope.patch('/repos/forked/repo/git/refs/heads/master').reply(200);
|
||||||
const config = await github.initRepo({
|
const config = await github.initRepo({
|
||||||
repository: 'some/repo',
|
repository: 'some/repo',
|
||||||
forkMode: 'true',
|
forkToken: 'true',
|
||||||
});
|
});
|
||||||
expect(config).toMatchSnapshot();
|
expect(config).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
@ -342,7 +342,7 @@ describe('modules/platform/github/index', () => {
|
||||||
scope.patch('/repos/forked/repo/git/refs/heads/master').reply(200);
|
scope.patch('/repos/forked/repo/git/refs/heads/master').reply(200);
|
||||||
const config = await github.initRepo({
|
const config = await github.initRepo({
|
||||||
repository: 'some/repo',
|
repository: 'some/repo',
|
||||||
forkMode: 'true',
|
forkToken: 'true',
|
||||||
});
|
});
|
||||||
expect(config).toMatchSnapshot();
|
expect(config).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
|
@ -246,7 +246,6 @@ export async function getJsonFile(
|
||||||
export async function initRepo({
|
export async function initRepo({
|
||||||
endpoint,
|
endpoint,
|
||||||
repository,
|
repository,
|
||||||
forkMode,
|
|
||||||
forkToken,
|
forkToken,
|
||||||
renovateUsername,
|
renovateUsername,
|
||||||
cloneSubmodules,
|
cloneSubmodules,
|
||||||
|
@ -371,9 +370,8 @@ export async function initRepo({
|
||||||
config.issueList = null;
|
config.issueList = null;
|
||||||
config.prList = null;
|
config.prList = null;
|
||||||
|
|
||||||
config.forkMode = !!forkMode;
|
if (forkToken) {
|
||||||
if (forkMode) {
|
logger.debug('Bot is in fork mode');
|
||||||
logger.debug('Bot is in forkMode');
|
|
||||||
config.forkToken = forkToken;
|
config.forkToken = forkToken;
|
||||||
// save parent name then delete
|
// save parent name then delete
|
||||||
config.parentRepo = config.repository;
|
config.parentRepo = config.repository;
|
||||||
|
@ -489,7 +487,7 @@ export async function initRepo({
|
||||||
|
|
||||||
const parsedEndpoint = URL.parse(platformConfig.endpoint);
|
const parsedEndpoint = URL.parse(platformConfig.endpoint);
|
||||||
// istanbul ignore else
|
// istanbul ignore else
|
||||||
if (forkMode) {
|
if (forkToken) {
|
||||||
logger.debug('Using forkToken for git init');
|
logger.debug('Using forkToken for git init');
|
||||||
parsedEndpoint.auth = config.forkToken ?? null;
|
parsedEndpoint.auth = config.forkToken ?? null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -624,7 +622,7 @@ export async function getPrList(): Promise<GhPr[]> {
|
||||||
if (!config.prList) {
|
if (!config.prList) {
|
||||||
const repo = config.parentRepo ?? config.repository;
|
const repo = config.parentRepo ?? config.repository;
|
||||||
const username =
|
const username =
|
||||||
!config.forkMode && !config.ignorePrAuthor && config.renovateUsername
|
!config.forkToken && !config.ignorePrAuthor && config.renovateUsername
|
||||||
? config.renovateUsername
|
? config.renovateUsername
|
||||||
: null;
|
: null;
|
||||||
// TODO: check null `repo` (#7154)
|
// TODO: check null `repo` (#7154)
|
||||||
|
@ -657,7 +655,7 @@ export async function findPr({
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.forkMode && config.repository !== p.sourceRepo) {
|
if (!config.forkToken && config.repository !== p.sourceRepo) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1415,7 +1413,7 @@ export async function createPr({
|
||||||
}: CreatePRConfig): Promise<GhPr | null> {
|
}: CreatePRConfig): Promise<GhPr | null> {
|
||||||
const body = sanitize(rawBody);
|
const body = sanitize(rawBody);
|
||||||
const base = targetBranch;
|
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)
|
// TODO: can `repository` be null? (#7154)
|
||||||
|
|
||||||
const head = `${config.repository!.split('/')[0]}:${sourceBranch}`;
|
const head = `${config.repository!.split('/')[0]}:${sourceBranch}`;
|
||||||
|
|
|
@ -80,7 +80,6 @@ export interface LocalRepoConfig {
|
||||||
prReviewsRequired: boolean;
|
prReviewsRequired: boolean;
|
||||||
repoForceRebase?: boolean;
|
repoForceRebase?: boolean;
|
||||||
parentRepo: string | null;
|
parentRepo: string | null;
|
||||||
forkMode?: boolean;
|
|
||||||
forkToken?: string;
|
forkToken?: string;
|
||||||
prList: GhPr[] | null;
|
prList: GhPr[] | null;
|
||||||
issueList: any[] | null;
|
issueList: any[] | null;
|
||||||
|
|
|
@ -37,7 +37,6 @@ export interface RepoParams {
|
||||||
repository: string;
|
repository: string;
|
||||||
endpoint?: string;
|
endpoint?: string;
|
||||||
gitUrl?: GitUrlOption;
|
gitUrl?: GitUrlOption;
|
||||||
forkMode?: string;
|
|
||||||
forkToken?: string;
|
forkToken?: string;
|
||||||
includeForks?: boolean;
|
includeForks?: boolean;
|
||||||
renovateUsername?: string;
|
renovateUsername?: string;
|
||||||
|
|
Loading…
Reference in a new issue