Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/cli/strategies/git-cz.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,14 @@ function gitCz(rawGitArgs, environment, adapterConfig) {
console.log(`cz-cli@${cliPackageJson.version}, ${adapterPackageJson.name}@${adapterPackageJson.version}\n`);
commit(sh, inquirer, process.cwd(), prompter, {
args: parsedGitCzArgs,
disableAppendPaths:true,
emitData:true,
quiet:false,
disableAppendPaths: true,
emitData: true,
quiet: false,
retryLastCommit
}, function(error) {
if (error) {
throw error;
}
// console.log('commit happened');
});
});

Expand Down
28 changes: 19 additions & 9 deletions src/commitizen/commit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'path';

import homeOrTmp from 'home-or-tmp';
import dedent from 'dedent';
import {commit as gitCommit, log} from '../git';
Expand All @@ -10,12 +11,10 @@ export default commit;
* Takes all of the final inputs needed in order to make dispatch a git commit
*/
function dispatchGitCommit(sh, repoPath, template, options, overrideOptions, done) {

// Commit the user input -- side effect that we'll test
gitCommit(sh, repoPath, template, { ...options, ...overrideOptions }, function() {
done(template);
gitCommit(sh, repoPath, template, { ...options, ...overrideOptions }, function(error) {
done(error, template);
});

}

/**
Expand All @@ -31,7 +30,7 @@ function commit(sh, inquirer, repoPath, prompter, options, done) {

// We want to use the last commit instead of the current commit,
// so lets override some options using the values from cache.
let {
let {
options: retryOptions,
overrideOptions: retryOverrideOptions,
template: retryTemplate
Expand All @@ -40,12 +39,23 @@ function commit(sh, inquirer, repoPath, prompter, options, done) {

} else {
// Get user input -- side effect that is hard to test
prompter(inquirer, function(template, overrideOptions) {

prompter(inquirer, function(error, template, overrideOptions) {
// Allow adapters to error out
// (error: Error?, template: String, overrideOptions: Object)
if (!(error instanceof Error)) {
overrideOptions = template;
template = error;
error = null;
}

if (error) {
return done(error);
}

// We don't want to add retries to the cache, only actual commands
cache.setCacheValueSync(cachePath, repoPath, { template, options, overrideOptions });
dispatchGitCommit(sh, repoPath, template, options, overrideOptions, done);
});
});
}

}
}
1 change: 1 addition & 0 deletions src/git/commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function commit(sh, repoPath, message, options, done) {
stdio: options.quiet ? 'ignore' : 'inherit'
}, function(error, stdout, stderror) {
if (error) {
error.message = [error.message, stderror].filter(Boolean).join('\n');
return done(error);
}
done();
Expand Down