From 06a2bab9a3931f72427ba2a7fb9e14013ba2cb3c Mon Sep 17 00:00:00 2001 From: OBKoro1 <1677593011@qq.com> Date: Wed, 8 Jan 2020 14:29:26 +0800 Subject: [PATCH] =?UTF-8?q?commit=E6=95=B0=E9=87=8F=E8=BF=87=E5=A4=A7?= =?UTF-8?q?=EF=BC=8C=E5=BC=BA=E5=88=B6=E7=AD=89=E5=BE=8510=E7=A7=92?= =?UTF-8?q?=E8=80=83=E8=99=91=E6=98=AF=E5=90=A6=E5=8F=96=E6=B6=88commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/commitHandle.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/models/commitHandle.ts b/src/models/commitHandle.ts index 173b26d..4a523b6 100644 --- a/src/models/commitHandle.ts +++ b/src/models/commitHandle.ts @@ -2,7 +2,7 @@ * Author : OBKoro1 * Date : 2019-12-30 16:59:30 * LastEditors : OBKoro1 - * LastEditTime : 2020-01-08 10:48:40 + * LastEditTime : 2020-01-08 14:28:37 * FilePath : /autoCommit/src/models/commitHandle.ts * Description : commit 具体操作 * https://github.com/OBKoro1 @@ -151,8 +151,22 @@ class CommitHandle { 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 (totalNum < 1) return; + if (totalNum === 0) return; outputLog('回滚中...'); await new Promise((resolve, reject) => { let cmd = `cd ${this.paramsObj.itemSrc} && git reset --hard HEAD~${totalNum}`;