Skip to content

Commit

Permalink
🐛 Explicit wrap messages with quotes (#1392)
Browse files Browse the repository at this point in the history
🐛 Add back missing quotes around message
  • Loading branch information
segersniels authored Jan 16, 2025
1 parent 8435dd4 commit 78cf5d9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/commands/commit/withClient/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { type Answers } from '../prompts.js'
const withClient = async (answers: Answers): Promise<void> => {
try {
const scope = answers.scope ? `(${answers.scope}): ` : ''
const title = `${answers.gitmoji} ${scope}${answers.title}`
const title = `"${answers.gitmoji} ${scope}${answers.title}"`
const isAutoAddEnabled = configurationVault.getAutoAdd()

if (await isHookCreated()) {
Expand All @@ -30,9 +30,10 @@ const withClient = async (answers: Answers): Promise<void> => {
'commit',
isAutoAddEnabled ? '-am' : '-m',
title,
...(answers.message ? ['-m', answers.message] : [])
...(answers.message ? ['-m', `"${answers.message}"`] : [])
],
{
shell: true,
buffer: false,
stdio: 'inherit'
}
Expand Down
10 changes: 6 additions & 4 deletions test/commands/commit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ describe('commit command', () => {
[
'commit',
'-m',
`${stubs.clientCommitAnswers.gitmoji} ${stubs.clientCommitAnswers.title}`,
`"${stubs.clientCommitAnswers.gitmoji} ${stubs.clientCommitAnswers.title}"`,
'-m',
stubs.clientCommitAnswers.message
`"${stubs.clientCommitAnswers.message}"`
],
{
shell: true,
buffer: false,
stdio: 'inherit'
}
Expand Down Expand Up @@ -87,11 +88,12 @@ describe('commit command', () => {
[
'commit',
'-am',
`${stubs.clientCommitAnswersWithScope.gitmoji} (${stubs.clientCommitAnswersWithScope.scope}): ${stubs.clientCommitAnswersWithScope.title}`,
`"${stubs.clientCommitAnswersWithScope.gitmoji} (${stubs.clientCommitAnswersWithScope.scope}): ${stubs.clientCommitAnswersWithScope.title}"`,
'-m',
stubs.clientCommitAnswersWithScope.message
`"${stubs.clientCommitAnswersWithScope.message}"`
],
{
shell: true,
buffer: false,
stdio: 'inherit'
}
Expand Down
4 changes: 2 additions & 2 deletions test/commands/stubs.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export const commitTitleInvalid = 'Invalid commit `title'

export const clientCommitAnswers = {
gitmoji: ':zap:',
title: 'Improving performance issues.',
message: 'Refactored code. Fixes #5'
title: '"Improving performance issues."',
message: '"Refactored code. Fixes #5"'
}

export const clientCommitAnswersWithScope = {
Expand Down

0 comments on commit 78cf5d9

Please sign in to comment.