From 1373a98e259b44c28c0547394bbd48643fe81911 Mon Sep 17 00:00:00 2001 From: Joey Perrott Date: Thu, 3 Sep 2020 13:54:31 -0700 Subject: [PATCH] feat(dev-infra): Allow local user ng-dev configuration to disable commit message wizard (#38701) As not all users, particularly contributors consistently contributing with a deep understanding of our commit message guidelines, will not want to rely on the commit message wizard, we allow a user to opt out of using this wizard during commit message creation. PR Close #38701 --- dev-infra/commit-message/wizard.ts | 12 +++++++++--- dev-infra/utils/config.ts | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/dev-infra/commit-message/wizard.ts b/dev-infra/commit-message/wizard.ts index fdf7d494969cd..654e41a0385f7 100644 --- a/dev-infra/commit-message/wizard.ts +++ b/dev-infra/commit-message/wizard.ts @@ -7,7 +7,8 @@ */ import {writeFileSync} from 'fs'; -import {info} from '../utils/console'; +import {getUserConfig} from '../utils/config'; +import {debug, info} from '../utils/console'; import {buildCommitMessage} from './builder'; @@ -25,10 +26,15 @@ const defaultCommitMessage = `(): export async function runWizard( args: {filePath: string, source?: PrepareCommitMsgHookSource, commitSha?: string}) { - // TODO(josephperrott): Add support for skipping wizard with local untracked config file + if (getUserConfig().commitMessage?.disableWizard) { + debug('Skipping commit message wizard due to enabled `commitMessage.disableWizard` option in'); + debug('user config.'); + process.exitCode = 0; + return; + } if (args.source !== undefined) { - info(`Skipping commit message wizard due because the commit was created via '${ + info(`Skipping commit message wizard because the commit was created via '${ args.source}' source`); process.exitCode = 0; return; diff --git a/dev-infra/utils/config.ts b/dev-infra/utils/config.ts index 8b8dff92ba727..832bf31d4e36d 100644 --- a/dev-infra/utils/config.ts +++ b/dev-infra/utils/config.ts @@ -120,7 +120,7 @@ function readConfigFile(configPath: string, returnEmptyObjectOnError = false): o debug(e); return {}; } - error(`Could not read configuration file at ${configPath}.'`); + error(`Could not read configuration file at ${configPath}.`); error(e); process.exit(1); } @@ -158,7 +158,7 @@ export function getRepoBaseDir() { * defined. * * @returns The user configuration object, or an empty object if no user configuration file is - * present. The object is a untyped object as there are no required user configurations. + * present. The object is an untyped object as there are no required user configurations. */ export function getUserConfig() { // If the global config is not defined, load it from the file system.