Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
devversion committed Feb 2, 2023
1 parent a98a616 commit 134c62f
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 27 deletions.
12 changes: 0 additions & 12 deletions docs/usage/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<!-- 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
11 changes: 11 additions & 0 deletions docs/usage/self-hosted-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<!-- prettier-ignore -->
!!! note
This option is only relevant if you set `forkToken`.

## prCommitsPerRunLimit

Parameter to reduce CI load.
Expand Down
1 change: 1 addition & 0 deletions lib/config/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class GlobalConfig {
'githubTokenWarn',
'localDir',
'migratePresets',
'prAllowMaintainerEdits',
'privateKey',
'privateKeyOld',
'gitTimeout',
Expand Down
6 changes: 3 additions & 3 deletions lib/config/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion lib/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export interface RepoGlobalConfig {
exposeAllEnv?: boolean;
githubTokenWarn?: boolean;
migratePresets?: Record<string, string>;
prAllowMaintainerEdits?: boolean;
privateKey?: string;
privateKeyOld?: string;
localDir?: string;
Expand Down Expand Up @@ -230,7 +231,6 @@ export interface RenovateConfig
postUpdateOptions?: string[];
prConcurrentLimit?: number;
prHourlyLimit?: number;
prAllowMaintainerEdits?: boolean;

defaultRegistryUrls?: string[];
registryUrls?: string[] | null;
Expand Down
15 changes: 10 additions & 5 deletions lib/modules/platform/github/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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
Expand All @@ -2194,31 +2198,32 @@ 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',
targetBranch: 'main',
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',
Expand Down
3 changes: 1 addition & 2 deletions lib/modules/platform/github/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,6 @@ export async function createPr({
prBody: rawBody,
labels,
draftPR = false,
allowMaintainerEdits,
platformOptions,
}: CreatePRConfig): Promise<GhPr | null> {
const body = sanitize(rawBody);
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion lib/modules/platform/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ export interface CreatePRConfig {
labels?: string[] | null;
platformOptions?: PlatformPrOptions;
draftPR?: boolean;
allowMaintainerEdits?: boolean;
}
export interface UpdatePrConfig {
number: number;
Expand Down
1 change: 0 additions & 1 deletion lib/workers/repository/config-migration/pr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ ${
sourceBranch: branchName,
// TODO #7154
targetBranch: config.defaultBranch!,
allowMaintainerEdits: config.prAllowMaintainerEdits,
prTitle,
prBody,
labels,
Expand Down
1 change: 0 additions & 1 deletion lib/workers/repository/onboarding/pr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion lib/workers/repository/update/pr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@ export async function ensurePr(
labels: prepareLabels(config),
platformOptions: getPlatformPrOptions(config),
draftPR: config.draftPR,
allowMaintainerEdits: config.prAllowMaintainerEdits,
});

incLimitedValue('PullRequests');
Expand Down

0 comments on commit 134c62f

Please sign in to comment.