From 541b2659bda3869cd1d78701c4e7dcd9d93a8bfb Mon Sep 17 00:00:00 2001 From: Markus Olsson Date: Thu, 31 Aug 2023 09:46:43 +0200 Subject: [PATCH] Don't assign gpgSignEnabled more than once --- app/src/lib/helpers/repo-rules.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/app/src/lib/helpers/repo-rules.ts b/app/src/lib/helpers/repo-rules.ts index 31cd35d6e1..e3fe43d64a 100644 --- a/app/src/lib/helpers/repo-rules.ts +++ b/app/src/lib/helpers/repo-rules.ts @@ -71,7 +71,7 @@ export async function parseRepoRules( repository: Repository ): Promise { const info = new RepoRulesInfo() - let gitConfigKeySet: boolean | null = null + let gpgSignEnabled: boolean | undefined = undefined for (const rule of rules) { // if a ruleset is null/undefined, then act as if the rule doesn't exist because @@ -102,17 +102,12 @@ export async function parseRepoRules( break case APIRepoRuleType.RequiredSignatures: - // check if the user has commit signing configured. if they do, the rule passes - // and doesn't need to be warned about. - if (gitConfigKeySet === null) { - gitConfigKeySet = await getBooleanConfigValue( - repository, - 'commit.gpgsign', - false - ) - } + // check if the user has commit signing configured. if they do, the rule + // passes and doesn't need to be warned about. + gpgSignEnabled ??= + (await getBooleanConfigValue(repository, 'commit.gpgsign')) ?? false - if (gitConfigKeySet !== true) { + if (gpgSignEnabled !== true) { info.signedCommitsRequired = info.signedCommitsRequired !== true ? enforced : true }