From d499d89107735d48e59002b424170f8a3fb00ce4 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Tue, 20 Jun 2023 13:40:53 +0200 Subject: [PATCH] fix(forkMode): disallow edits by maintainers when forkOrg is set (#22892) --- docs/usage/self-hosted-configuration.md | 1 + lib/modules/platform/github/index.ts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/docs/usage/self-hosted-configuration.md b/docs/usage/self-hosted-configuration.md index e0bdd18a35..f3d6b09997 100644 --- a/docs/usage/self-hosted-configuration.md +++ b/docs/usage/self-hosted-configuration.md @@ -419,6 +419,7 @@ It will also override any settings in `packageRules`. This configuration option lets you choose an organization you want repositories forked into when "fork mode" is enabled. It must be set to a GitHub Organization name and not a GitHub user account. +When set, "allow edits by maintainers" will be false for PRs because GitHub does not allow this setting for organizations. This can be used if you're migrating from user-based forks to organization-based forks. diff --git a/lib/modules/platform/github/index.ts b/lib/modules/platform/github/index.ts index 8b477ebbba..5370c458a7 100644 --- a/lib/modules/platform/github/index.ts +++ b/lib/modules/platform/github/index.ts @@ -484,6 +484,7 @@ export async function initRepo({ if (forkToken) { logger.debug('Bot is in fork mode'); + config.forkOrg = forkOrg; config.forkToken = forkToken; // save parent name then delete config.parentRepo = config.repository; @@ -1572,6 +1573,7 @@ export async function createPr({ if (config.forkToken) { options.token = config.forkToken; options.body.maintainer_can_modify = + !config.forkOrg && platformOptions?.forkModeDisallowMaintainerEdits !== true; } logger.debug({ title, head, base, draft: draftPR }, 'Creating PR'); -- GitLab