From 78cf5d970260989cbbf36a4ed53e693224c2d57d Mon Sep 17 00:00:00 2001 From: Niels Date: Thu, 16 Jan 2025 09:30:53 +0100 Subject: [PATCH] :bug: Explicit wrap messages with quotes (#1392) :bug: Add back missing quotes around message --- src/commands/commit/withClient/index.ts | 5 +++-- test/commands/commit.spec.js | 10 ++++++---- test/commands/stubs.js | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/commands/commit/withClient/index.ts b/src/commands/commit/withClient/index.ts index fa48ff738..d90989afc 100644 --- a/src/commands/commit/withClient/index.ts +++ b/src/commands/commit/withClient/index.ts @@ -8,7 +8,7 @@ import { type Answers } from '../prompts.js' const withClient = async (answers: Answers): Promise => { 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()) { @@ -30,9 +30,10 @@ const withClient = async (answers: Answers): Promise => { 'commit', isAutoAddEnabled ? '-am' : '-m', title, - ...(answers.message ? ['-m', answers.message] : []) + ...(answers.message ? ['-m', `"${answers.message}"`] : []) ], { + shell: true, buffer: false, stdio: 'inherit' } diff --git a/test/commands/commit.spec.js b/test/commands/commit.spec.js index 04f1c09fb..ee929ab5e 100644 --- a/test/commands/commit.spec.js +++ b/test/commands/commit.spec.js @@ -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' } @@ -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' } diff --git a/test/commands/stubs.js b/test/commands/stubs.js index d2e71df37..e301c9414 100644 --- a/test/commands/stubs.js +++ b/test/commands/stubs.js @@ -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 = {