Skip to content

Commit

Permalink
feat(dev-infra): Allow local user ng-dev configuration to disable com…
Browse files Browse the repository at this point in the history
…mit 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
  • Loading branch information
josephperrott authored and atscott committed Sep 9, 2020
1 parent 18d911d commit 7669bd8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions dev-infra/commit-message/wizard.ts
Expand Up @@ -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';

Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions dev-infra/utils/config.ts
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 7669bd8

Please sign in to comment.