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
This commit is contained in:
Joey Perrott 2020-09-03 13:54:31 -07:00 committed by atscott
parent 1ed6913b8b
commit 1373a98e25
2 changed files with 11 additions and 5 deletions

View File

@ -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 = `<type>(<scope>): <summary>
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;

View File

@ -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.