diff --git a/src/cli/strategies/git-cz.js b/src/cli/strategies/git-cz.js index dad0ebf1..059c5f33 100644 --- a/src/cli/strategies/git-cz.js +++ b/src/cli/strategies/git-cz.js @@ -41,6 +41,7 @@ function gitCz (rawGitArgs, environment, adapterConfig) { let resolvedAdapterConfigPath = resolveAdapterPath(adapterConfig.path); let resolvedAdapterRootPath = findRoot(resolvedAdapterConfigPath); let prompter = getPrompter(adapterConfig.path); + let shouldStageAllFiles = rawGitArgs.includes('-a') || rawGitArgs.includes('--all'); isClean(process.cwd(), function (error, stagingIsClean) { if (error) { @@ -67,6 +68,6 @@ function gitCz (rawGitArgs, environment, adapterConfig) { throw error; } }); - }); + }, shouldStageAllFiles); } diff --git a/src/commitizen/staging.js b/src/commitizen/staging.js index c485b5dd..c8a81c29 100644 --- a/src/commitizen/staging.js +++ b/src/commitizen/staging.js @@ -5,8 +5,8 @@ export { isClean }; /** * Asynchrounously determines if the staging area is clean */ -function isClean (repoPath, done) { - exec('git diff --no-ext-diff --name-only && git diff --no-ext-diff --cached --name-only', { +function isClean (repoPath, done, stageAllFiles) { + exec(`git diff --cached --no-ext-diff --name-only ${!!stageAllFiles ? '&& git diff --no-ext-diff --name-only' : ''}`, { maxBuffer: Infinity, cwd: repoPath }, function (error, stdout) {