diff --git a/CHANGELOG.md b/CHANGELOG.md
index ace045e..99f6b6d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,12 @@
+
+
+
+
+
+
### [V1.0.0]
- Initial release
\ No newline at end of file
diff --git a/README.md b/README.md
index bfedef5..afd71fd 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,4 @@
# 用于学习交流
-
-
\ No newline at end of file
diff --git a/src/models/commitHandle.ts b/src/models/commitHandle.ts
index 55ff5e3..bddf6d5 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-04 15:14:39
+ * LastEditTime : 2020-01-07 22:30:03
* FilePath : /autoCommit/src/models/commitHandle.ts
* Description : commit 具体操作
* https://github.com/OBKoro1
@@ -91,6 +91,10 @@ class CommitHandle {
if (this.cancelCommit()) break;
// 每个日期commit次数
let dayCommitNumber = this.paramsObj.commitNumber;
+ if (this.paramsObj.randomCommit) {
+ // 随机commit次数
+ dayCommitNumber = RandomNumber(1, this.paramsObj.commitNumber);
+ }
if (item.commitNumber !== 0) {
// 如果该范围有commit次数 则用该范围的
dayCommitNumber = item.commitNumber;
@@ -137,12 +141,43 @@ class CommitHandle {
}, 1000);
});
}
- await outputLog(`${totalNum + 1}commit内容`, commitContent);
- await outputLog(`${totalNum + 1}commit信息`, commitMsg);
+ outputLog(`${totalNum + 1}commit内容`, commitContent);
+ outputLog(`${totalNum + 1}commit信息`, commitMsg);
totalNum++;
}
}
- this.myExecSync(`cd ${this.paramsObj.itemSrc} && git pull && git push`)
+ if (this.cancelCommit()) {
+ if (totalNum < 1) return;
+ outputLog('回滚中...');
+ const res = await new Promise((resolve, reject) => {
+ let cmd = `cd ${this.paramsObj.itemSrc} && git reset --hard HEAD~${totalNum}`;
+ exec(cmd, (error, stdout, stderr) => {
+ if (error) {
+ outputLog(`执行命令出错:${cmd}`);
+ outputLog(`回滚失败:${error}`, stderr);
+ reject(error);
+ return;
+ }
+ outputLog('回滚成功:', stdout);
+ resolve(stdout);
+ });
+ });
+ } else {
+ outputLog('提交中...');
+ const res = await new Promise((resolve, reject) => {
+ let cmd = `cd ${this.paramsObj.itemSrc} && git pull && git push`;
+ exec(cmd, (error, stdout, stderr) => {
+ if (error) {
+ outputLog(`执行命令出错:${cmd}`);
+ outputLog(`错误信息:${error}`, stderr);
+ reject(error);
+ return;
+ }
+ resolve(stdout);
+ });
+ });
+ outputLog('提交信息:', res);
+ }
this.commitEnd(totalNum);
}
commitEnd(totalNum: number) {
diff --git a/src/views/autoCommit.html b/src/views/autoCommit.html
index 58e537c..106af37 100644
--- a/src/views/autoCommit.html
+++ b/src/views/autoCommit.html
@@ -44,12 +44,33 @@
+
+
+
+
+
+
+
+
+
-
+
+
删除
@@ -156,6 +177,7 @@
form: {
// TODO: 保存其他几个参数
// itemSrc: '/Users/koro/work/web_my/testCommit',
+ randomCommit: true,
itemSrc: '点击选择要commit的项目文件夹',
fileName: 'commit.md',
commitMsg: 'autoCommit',
@@ -165,7 +187,7 @@
commitNumber: 0
}
],
- commitNumber: 1,
+ commitNumber: 10,
},
rules: {
'itemSrc': [
@@ -326,6 +348,13 @@
commitNumber: 0
});
},
+ switchChange(value){
+ if(value){
+ this.form.commitNumber = 10;
+ }else{
+ this.form.commitNumber = 1;
+ }
+ },
fileNameChange(value) {
if (value === '') {
this.form.fileName = 'commit.md'