Skip to content

Commit 8c9db67

Browse files
committed
fix(ng-dev): move disallowFixup to commit message config
This option needs to be configurable from the config
1 parent fe58c3e commit 8c9db67

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

ng-dev/commit-message/config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ export interface CommitMessageConfig {
1414
minBodyLength: number;
1515
minBodyLengthTypeExcludes?: string[];
1616
scopes: string[];
17+
disallowFixup?: boolean;
1718
}
1819

1920
/** Assert the provided config contains a `CommitMessageConfig`. */
2021
export function assertValidCommitMessageConfig<T extends NgDevConfig>(
21-
config: T & Partial<{commitMessage: CommitMessageConfig}>,
22-
): asserts config is T & {commitMessage: CommitMessageConfig} {
22+
config: T & Partial<{commitMessage: CommitMessageConfig; disallowFixup?: boolean}>,
23+
): asserts config is T & {commitMessage: CommitMessageConfig; disallowFixup?: boolean} {
2324
if (config.commitMessage === undefined) {
2425
throw new ConfigValidationError(`No configuration defined for "commitMessage"`);
2526
}

ng-dev/commit-message/validate.spec.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,24 +269,27 @@ describe('validate-commit-message.js', () => {
269269

270270
describe('with `disallowFixup`', () => {
271271
it('when true should fail', async () => {
272+
setConfig({...config, commitMessage: {...config.commitMessage, disallowFixup: true}});
273+
272274
const msg = 'fixup! foo';
273275

274276
expectValidationResult(
275277
await validateCommitMessage(msg, {
276-
disallowFixup: true,
277278
nonFixupCommitHeaders: ['foo', 'bar', 'baz'],
278279
}),
279280
INVALID,
280-
['The commit must be manually fixed-up into the target commit as fixup commits are disallowed'],
281+
[
282+
'The commit must be manually fixed-up into the target commit as fixup commits are disallowed',
283+
],
281284
);
282285
});
283286

284287
it('when false should pass', async () => {
288+
setConfig({...config, commitMessage: {...config.commitMessage, disallowFixup: false}});
285289
const msg = 'fixup! foo';
286290

287291
expectValidationResult(
288292
await validateCommitMessage(msg, {
289-
disallowFixup: false,
290293
nonFixupCommitHeaders: ['foo', 'bar', 'baz'],
291294
}),
292295
VALID,

ng-dev/commit-message/validate.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {Commit, parseCommitMessage} from './parse.js';
1515
/** Options for commit message validation. */
1616
export interface ValidateCommitMessageOptions {
1717
disallowSquash?: boolean;
18-
disallowFixup?: boolean;
1918
nonFixupCommitHeaders?: string[];
2019
}
2120

@@ -91,7 +90,7 @@ export async function validateCommitMessage(
9190
// stripping the `fixup! ` prefix), otherwise we assume this verification will happen in another
9291
// check.
9392
if (commit.isFixup) {
94-
if (options.disallowFixup) {
93+
if (config.disallowFixup) {
9594
errors.push(
9695
'The commit must be manually fixed-up into the target commit as fixup commits are disallowed',
9796
);

0 commit comments

Comments
 (0)