commit数量过大,强制等待10秒考虑是否取消commit

This commit is contained in:
OBKoro1 2020-01-08 14:29:26 +08:00
parent 77facfe79f
commit 06a2bab9a3

View File

@ -2,7 +2,7 @@
* Author : OBKoro1 * Author : OBKoro1
* Date : 2019-12-30 16:59:30 * Date : 2019-12-30 16:59:30
* LastEditors : OBKoro1 * LastEditors : OBKoro1
* LastEditTime : 2020-01-08 10:48:40 * LastEditTime : 2020-01-08 14:28:37
* FilePath : /autoCommit/src/models/commitHandle.ts * FilePath : /autoCommit/src/models/commitHandle.ts
* Description : commit * Description : commit
* https://github.com/OBKoro1 * https://github.com/OBKoro1
@ -151,8 +151,22 @@ class CommitHandle {
totalNum++; totalNum++;
} }
} }
this.pushCommitFn(totalNum);
}
async pushCommitFn(totalNum: number) {
const commitNumberBig = 100; // commit数量过大
if (totalNum > commitNumberBig) {
outputLog(`commit数量:${totalNum}`);
outputLog('commit数量超过100次,请考虑10秒钟是否需要取消commit');
await new Promise((resolve, reject) => {
const thinkNumber = 10000; // 考虑时间 避免运行过快导致误操作
setTimeout(() => {
resolve();
}, thinkNumber);
});
}
if (this.cancelCommit()) { if (this.cancelCommit()) {
if (totalNum < 1) return; if (totalNum === 0) return;
outputLog('回滚中...'); outputLog('回滚中...');
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
let cmd = `cd ${this.paramsObj.itemSrc} && git reset --hard HEAD~${totalNum}`; let cmd = `cd ${this.paramsObj.itemSrc} && git reset --hard HEAD~${totalNum}`;