From 134c62f6708dbc52c6511f37ae2fa3b39c69ac1b Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Thu, 2 Feb 2023 17:02:26 +0000 Subject: [PATCH] Address feedback --- docs/usage/configuration-options.md | 12 ------------ docs/usage/self-hosted-configuration.md | 11 +++++++++++ lib/config/global.ts | 1 + lib/config/options/index.ts | 6 +++--- lib/config/types.ts | 2 +- lib/modules/platform/github/index.spec.ts | 15 ++++++++++----- lib/modules/platform/github/index.ts | 3 +-- lib/modules/platform/types.ts | 1 - .../repository/config-migration/pr/index.ts | 1 - lib/workers/repository/onboarding/pr/index.ts | 1 - lib/workers/repository/update/pr/index.ts | 1 - 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index 47ba500417d94c8..5f2bc37017576f4 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -2181,18 +2181,6 @@ Defaults to `update`, but can also be set to `branch`. This sets the level the postUpgradeTask runs on, if set to `update` the postUpgradeTask will be executed for every dependency on the branch. If set to `branch` the postUpgradeTask is executed for the whole branch. -## prAllowMaintainerEdits - -This setting controls whether pull requests created by Renovate will allow edits by maintainers. - -When Renovate operates in a fork, this allows project maintainers to make manual changes -to the Renovate PR branch— without needing to create another new PR. - - -!!! note - If Renovate does not operate in a fork, maintainers can make modifications regardless - as they have access to upstream branches. - ## prBodyColumns Use this array to provide a list of column names you wish to include in the PR tables. diff --git a/docs/usage/self-hosted-configuration.md b/docs/usage/self-hosted-configuration.md index b96e7861a4c8eb1..c6cbb41e4a52401 100644 --- a/docs/usage/self-hosted-configuration.md +++ b/docs/usage/self-hosted-configuration.md @@ -555,6 +555,17 @@ It also may mean that ignored directories like `node_modules` can be preserved a ## platform +## prAllowMaintainerEdits + +Use `prAllowMaintainerEdits` to control if maintainers can edit Renovate's pull requests. + +When Renovate runs in a fork, this allows project maintainers to make manual changes to the +Renovate PR branch, without needing to create another new PR. + + +!!! note + This option is only relevant if you set `forkToken`. + ## prCommitsPerRunLimit Parameter to reduce CI load. diff --git a/lib/config/global.ts b/lib/config/global.ts index c1b4e92455f6347..5f3cd03f7546e5a 100644 --- a/lib/config/global.ts +++ b/lib/config/global.ts @@ -22,6 +22,7 @@ export class GlobalConfig { 'githubTokenWarn', 'localDir', 'migratePresets', + 'prAllowMaintainerEdits', 'privateKey', 'privateKeyOld', 'gitTimeout', diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index 0172c86350255cb..0e91d10e674c25e 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -1557,11 +1557,11 @@ const options: RenovateOptions[] = [ }, { name: 'prAllowMaintainerEdits', - description: - 'Whether pull requests created should allow for maintainer edits.', + description: 'Decides if maintainers can edit Renovate pull requests.', type: 'boolean', - supportedPlatforms: ['github', 'gitlab'], + supportedPlatforms: ['github'], default: true, + globalOnly: true, }, { name: 'prCreation', diff --git a/lib/config/types.ts b/lib/config/types.ts index 3e68c82f481d579..524c0474675f4e3 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -125,6 +125,7 @@ export interface RepoGlobalConfig { exposeAllEnv?: boolean; githubTokenWarn?: boolean; migratePresets?: Record; + prAllowMaintainerEdits?: boolean; privateKey?: string; privateKeyOld?: string; localDir?: string; @@ -230,7 +231,6 @@ export interface RenovateConfig postUpdateOptions?: string[]; prConcurrentLimit?: number; prHourlyLimit?: number; - prAllowMaintainerEdits?: boolean; defaultRegistryUrls?: string[]; registryUrls?: string[] | null; diff --git a/lib/modules/platform/github/index.spec.ts b/lib/modules/platform/github/index.spec.ts index c3dd9888bc87d19..49d095efac081d3 100644 --- a/lib/modules/platform/github/index.spec.ts +++ b/lib/modules/platform/github/index.spec.ts @@ -2122,6 +2122,10 @@ describe('modules/platform/github/index', () => { }); describe('createPr()', () => { + beforeEach(() => { + GlobalConfig.reset(); + }); + it('should create and return a PR object', async () => { const scope = httpMock.scope(githubApiHost); initRepoMock(scope, 'some/repo'); @@ -2181,7 +2185,7 @@ describe('modules/platform/github/index', () => { expect(pr).toMatchObject({ number: 123 }); }); - it('should allow maintainer edits if enabled via options', async () => { + it('should allow maintainer edits if enabled via global option', async () => { const scope = httpMock.scope(githubApiHost); initRepoMock(scope, 'some/repo'); scope @@ -2194,6 +2198,7 @@ describe('modules/platform/github/index', () => { number: 123, head: { repo: { full_name: 'some/repo' }, ref: 'some-branch' }, }); + GlobalConfig.set({ prAllowMaintainerEdits: true }); await github.initRepo({ repository: 'some/repo' }); const pr = await github.createPr({ sourceBranch: 'some-branch', @@ -2201,24 +2206,24 @@ describe('modules/platform/github/index', () => { prTitle: 'PR title', prBody: 'PR can be edited by maintainers.', labels: null, - allowMaintainerEdits: true, }); expect(pr).toMatchObject({ number: 123 }); }); - it('should not allow maintainer edits if not explicitly set', async () => { + it('should not allow maintainer edits if disabled via global option', async () => { const scope = httpMock.scope(githubApiHost); initRepoMock(scope, 'some/repo'); scope .post( '/repos/some/repo/pulls', - // Ensure the `maintainer_can_modify` option is unset in the REST API request. - (body) => body.maintainer_can_modify === undefined + // Ensure the `maintainer_can_modify` option is `false` in the REST API request. + (body) => body.maintainer_can_modify === false ) .reply(200, { number: 123, head: { repo: { full_name: 'some/repo' }, ref: 'some-branch' }, }); + GlobalConfig.set({ prAllowMaintainerEdits: false }); await github.initRepo({ repository: 'some/repo' }); const pr = await github.createPr({ sourceBranch: 'some-branch', diff --git a/lib/modules/platform/github/index.ts b/lib/modules/platform/github/index.ts index 6a97d2de690360c..a020a60a8e829ba 100644 --- a/lib/modules/platform/github/index.ts +++ b/lib/modules/platform/github/index.ts @@ -1479,7 +1479,6 @@ export async function createPr({ prBody: rawBody, labels, draftPR = false, - allowMaintainerEdits, platformOptions, }: CreatePRConfig): Promise { const body = sanitize(rawBody); @@ -1495,7 +1494,7 @@ export async function createPr({ base, body, draft: draftPR, - maintainer_can_modify: allowMaintainerEdits, + maintainer_can_modify: !!GlobalConfig.get('prAllowMaintainerEdits'), }, }; // istanbul ignore if diff --git a/lib/modules/platform/types.ts b/lib/modules/platform/types.ts index 8bc5384768e0aa4..3dc626c3b09cb71 100644 --- a/lib/modules/platform/types.ts +++ b/lib/modules/platform/types.ts @@ -103,7 +103,6 @@ export interface CreatePRConfig { labels?: string[] | null; platformOptions?: PlatformPrOptions; draftPR?: boolean; - allowMaintainerEdits?: boolean; } export interface UpdatePrConfig { number: number; diff --git a/lib/workers/repository/config-migration/pr/index.ts b/lib/workers/repository/config-migration/pr/index.ts index f2ecedaa574ff42..dca8cf475f0f890 100644 --- a/lib/workers/repository/config-migration/pr/index.ts +++ b/lib/workers/repository/config-migration/pr/index.ts @@ -100,7 +100,6 @@ ${ sourceBranch: branchName, // TODO #7154 targetBranch: config.defaultBranch!, - allowMaintainerEdits: config.prAllowMaintainerEdits, prTitle, prBody, labels, diff --git a/lib/workers/repository/onboarding/pr/index.ts b/lib/workers/repository/onboarding/pr/index.ts index 28a22508bc954ff..e562fe95ea5cf68 100644 --- a/lib/workers/repository/onboarding/pr/index.ts +++ b/lib/workers/repository/onboarding/pr/index.ts @@ -174,7 +174,6 @@ If you need any further assistance then you can also [request help here](${ const pr = await platform.createPr({ sourceBranch: config.onboardingBranch!, targetBranch: config.defaultBranch!, - allowMaintainerEdits: config.prAllowMaintainerEdits, prTitle: config.onboardingPrTitle!, prBody, labels, diff --git a/lib/workers/repository/update/pr/index.ts b/lib/workers/repository/update/pr/index.ts index 0ab2953466e9659..5091ef1abf259cb 100644 --- a/lib/workers/repository/update/pr/index.ts +++ b/lib/workers/repository/update/pr/index.ts @@ -353,7 +353,6 @@ export async function ensurePr( labels: prepareLabels(config), platformOptions: getPlatformPrOptions(config), draftPR: config.draftPR, - allowMaintainerEdits: config.prAllowMaintainerEdits, }); incLimitedValue('PullRequests');