From 1f5ae77307c4b01b09b241294c0b93eb94579c9e Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Tue, 24 Jan 2023 15:02:17 +0000 Subject: [PATCH] feat: add support for controlling whether PRs can be edited by maintainers Platforms like GitHub, or Gitlab supports options to control whether a PR can be modified by maintainers. See e.g. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork This commit introduces a way to control this in Renovate. The option will default to `true`. --- docs/usage/configuration-options.md | 12 ++++++++++++ lib/config/options/index.ts | 8 ++++++++ lib/config/types.ts | 1 + lib/modules/platform/types.ts | 1 + lib/workers/repository/config-migration/pr/index.ts | 1 + lib/workers/repository/onboarding/pr/index.ts | 1 + lib/workers/repository/update/pr/index.ts | 1 + 7 files changed, 25 insertions(+) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index 5f2bc37017576f4..47ba500417d94c8 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -2181,6 +2181,18 @@ 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/lib/config/options/index.ts b/lib/config/options/index.ts index 6a2aed7a40410b0..0172c86350255cb 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -1555,6 +1555,14 @@ const options: RenovateOptions[] = [ allowedValues: ['strict', 'flexible', 'none'], default: 'strict', }, + { + name: 'prAllowMaintainerEdits', + description: + 'Whether pull requests created should allow for maintainer edits.', + type: 'boolean', + supportedPlatforms: ['github', 'gitlab'], + default: true, + }, { name: 'prCreation', description: 'When to create the PR for a branch.', diff --git a/lib/config/types.ts b/lib/config/types.ts index 5e67b80df5683b1..3e68c82f481d579 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -230,6 +230,7 @@ export interface RenovateConfig postUpdateOptions?: string[]; prConcurrentLimit?: number; prHourlyLimit?: number; + prAllowMaintainerEdits?: boolean; defaultRegistryUrls?: string[]; registryUrls?: string[] | null; diff --git a/lib/modules/platform/types.ts b/lib/modules/platform/types.ts index 3dc626c3b09cb71..8bc5384768e0aa4 100644 --- a/lib/modules/platform/types.ts +++ b/lib/modules/platform/types.ts @@ -103,6 +103,7 @@ 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 dca8cf475f0f890..f2ecedaa574ff42 100644 --- a/lib/workers/repository/config-migration/pr/index.ts +++ b/lib/workers/repository/config-migration/pr/index.ts @@ -100,6 +100,7 @@ ${ 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 e562fe95ea5cf68..28a22508bc954ff 100644 --- a/lib/workers/repository/onboarding/pr/index.ts +++ b/lib/workers/repository/onboarding/pr/index.ts @@ -174,6 +174,7 @@ 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 5091ef1abf259cb..0ab2953466e9659 100644 --- a/lib/workers/repository/update/pr/index.ts +++ b/lib/workers/repository/update/pr/index.ts @@ -353,6 +353,7 @@ export async function ensurePr( labels: prepareLabels(config), platformOptions: getPlatformPrOptions(config), draftPR: config.draftPR, + allowMaintainerEdits: config.prAllowMaintainerEdits, }); incLimitedValue('PullRequests');