Skip to content

Commit c67a8ad

Browse files
committed
fix: add merge commit support to validation script
- Add isSpecialCommit function to detect merge/revert/fixup commits - Skip validation for special Git commit types - Update both ESM and CommonJS versions - Remove unused printWelcome function from banner.ts
1 parent 4f68eaf commit c67a8ad

File tree

4 files changed

+68
-10
lines changed

4 files changed

+68
-10
lines changed

bin/index.cjs.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,12 @@ async function handleCheckCommand() {
441441
console.log(commitMessage);
442442
console.log('');
443443

444+
// Check if this is a special commit that should be excluded from validation
445+
if (isSpecialCommit(commitMessage)) {
446+
console.log('✓ Special commit detected (merge/revert/fixup) - skipping validation');
447+
process.exit(0);
448+
}
449+
444450
// Use inline validation logic for CommonJS compatibility
445451
const validation = validateCommitMessage(commitMessage, config);
446452

@@ -475,6 +481,32 @@ async function handleCheckCommand() {
475481
}
476482
}
477483

484+
function isSpecialCommit(message: string): boolean {
485+
const header = message.split('\n')[0] || '';
486+
487+
// Check for merge commits
488+
if (header.startsWith('Merge ')) {
489+
return true;
490+
}
491+
492+
// Check for revert commits
493+
if (header.startsWith('Revert ')) {
494+
return true;
495+
}
496+
497+
// Check for fixup commits
498+
if (header.startsWith('fixup! ') || header.startsWith('squash! ')) {
499+
return true;
500+
}
501+
502+
// Check for initial commits
503+
if (header.toLowerCase().includes('initial commit')) {
504+
return true;
505+
}
506+
507+
return false;
508+
}
509+
478510
function parseCommitMessage(message: string) {
479511
const lines = message.split('\n');
480512
const header = lines[0] || '';

scripts/check-commit.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,35 @@ function getLatestCommitMessage(): string {
4848
}
4949
}
5050

51+
/**
52+
* Check if commit message is a special Git commit type that should be excluded from validation
53+
*/
54+
function isSpecialCommit(message: string): boolean {
55+
const header = message.split('\n')[0] || '';
56+
57+
// Check for merge commits
58+
if (header.startsWith('Merge ')) {
59+
return true;
60+
}
61+
62+
// Check for revert commits
63+
if (header.startsWith('Revert ')) {
64+
return true;
65+
}
66+
67+
// Check for fixup commits
68+
if (header.startsWith('fixup! ') || header.startsWith('squash! ')) {
69+
return true;
70+
}
71+
72+
// Check for initial commits
73+
if (header.toLowerCase().includes('initial commit')) {
74+
return true;
75+
}
76+
77+
return false;
78+
}
79+
5180
/**
5281
* Parse a conventional commit message
5382
*/
@@ -155,6 +184,12 @@ async function main() {
155184
console.log(commitMessage);
156185
console.log('');
157186

187+
// Check if this is a special commit that should be excluded from validation
188+
if (isSpecialCommit(commitMessage)) {
189+
console.log('✓ Special commit detected (merge/revert/fixup) - skipping validation');
190+
process.exit(0);
191+
}
192+
158193
// Parse commit message
159194
const parsed = parseCommitMessage(commitMessage);
160195

@@ -197,4 +232,4 @@ if (import.meta.url === `file://${process.argv[1]}`) {
197232
main();
198233
}
199234

200-
export { validateCommit, parseCommitMessage, loadConfig };
235+
export { validateCommit, parseCommitMessage, loadConfig, isSpecialCommit };

src/ui/banner.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,6 @@ export async function typeWriter(text: string, delay: number = 50): Promise<void
116116
console.log('');
117117
}
118118

119-
export function printWelcome(): void {
120-
console.log(chalk.hex(BRAND_COLORS.muted)('┌─────────────────────────────────────────────────────────────────────────────────────────┐'));
121-
console.log(chalk.hex(BRAND_COLORS.muted)('│') + chalk.hex(BRAND_COLORS.primary).bold(' Welcome to Commitweave! 🧶 ') + chalk.hex(BRAND_COLORS.muted)('│'));
122-
console.log(chalk.hex(BRAND_COLORS.muted)('│') + chalk.white(' A modern CLI for smart, structured git commits ') + chalk.hex(BRAND_COLORS.muted)('│'));
123-
console.log(chalk.hex(BRAND_COLORS.muted)('│') + chalk.hex(BRAND_COLORS.accent)(' Powered by GLINR STUDIOS ') + chalk.hex(BRAND_COLORS.muted)('│'));
124-
console.log(chalk.hex(BRAND_COLORS.muted)('└─────────────────────────────────────────────────────────────────────────────────────────┘'));
125-
console.log('');
126-
}
127119

128120
export function printFeatureHighlight(): void {
129121
console.log(chalk.hex(BRAND_COLORS.accent)('✨ Features:'));

test-merge.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)