Skip to content

Commit

Permalink
feat: add support for controlling whether PRs can be edited by mainta…
Browse files Browse the repository at this point in the history
…iners

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`.
  • Loading branch information
devversion committed Feb 2, 2023
1 parent 9e41961 commit 1f5ae77
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/usage/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<!-- prettier-ignore -->
!!! 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.
Expand Down
8 changes: 8 additions & 0 deletions lib/config/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down
1 change: 1 addition & 0 deletions lib/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ export interface RenovateConfig
postUpdateOptions?: string[];
prConcurrentLimit?: number;
prHourlyLimit?: number;
prAllowMaintainerEdits?: boolean;

defaultRegistryUrls?: string[];
registryUrls?: string[] | null;
Expand Down
1 change: 1 addition & 0 deletions lib/modules/platform/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export interface CreatePRConfig {
labels?: string[] | null;
platformOptions?: PlatformPrOptions;
draftPR?: boolean;
allowMaintainerEdits?: boolean;
}
export interface UpdatePrConfig {
number: number;
Expand Down
1 change: 1 addition & 0 deletions lib/workers/repository/config-migration/pr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ ${
sourceBranch: branchName,
// TODO #7154
targetBranch: config.defaultBranch!,
allowMaintainerEdits: config.prAllowMaintainerEdits,
prTitle,
prBody,
labels,
Expand Down
1 change: 1 addition & 0 deletions lib/workers/repository/onboarding/pr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions lib/workers/repository/update/pr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ export async function ensurePr(
labels: prepareLabels(config),
platformOptions: getPlatformPrOptions(config),
draftPR: config.draftPR,
allowMaintainerEdits: config.prAllowMaintainerEdits,
});

incLimitedValue('PullRequests');
Expand Down

0 comments on commit 1f5ae77

Please sign in to comment.