Skip to content

Commit

Permalink
fix(history): 🐛Keep history only when commit message fails
Browse files Browse the repository at this point in the history
  • Loading branch information
vivaxy committed Jun 13, 2019
1 parent 677a37e commit 1379167
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions commands/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const gitFetch = require('../git/commands/gitFetch.js');
const prompt = require('../lib/prompt.js');
const GacpError = require('../errors/GacpError.js');
const errorTypes = require('../configs/errorTypes.js');
const { removeHistory } = require('../lib/history.js');

const getNow = () => {
return new Date().getTime();
Expand Down Expand Up @@ -51,6 +52,8 @@ const runTasks = async () => {
const commitMessage = await prompt();
await gitAdd();
await gitCommit(commitMessage);
// If commit success, remove last commit message
await removeHistory();
return await gitPush();
};

Expand Down
4 changes: 4 additions & 0 deletions lib/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ exports.setHistory = async function(history) {
debugHistory(`write: ${JSON.stringify(history)}`);
await fse.outputFile(historyFile, JSON.stringify(history, null, 2));
};

exports.removeHistory = async function() {
await fse.remove(historyFile);
};

0 comments on commit 1379167

Please sign in to comment.