Merge branch 'koro_branch' of https://github.com/OBKoro1/autoCommit into koro_branch

This commit is contained in:
OBKoro1 2020-08-31 11:33:47 +08:00
commit 2283ae012d
4 changed files with 18 additions and 28 deletions

View File

@ -7,6 +7,10 @@
* 增加新功能:超过一定天数范围内,随机部分天数不提交`commit`,没有绿格子,看起来更逼真。
* 重写wiki配置文档
### [V1.0.4]
* 设置最大单次commit次数为88
* 修复window系统下进入其他磁盘报错的问题
### [V1.0.3]

View File

@ -3,7 +3,7 @@
"displayName": "Auto Commit",
"description": "自动提交commit到github",
"publisher": "OBKoro1",
"version": "1.0.3",
"version": "1.0.4",
"scripts": {
"build": "vsce package",
"vscode:prepublish": "webpack --mode production",

View File

@ -2,7 +2,7 @@
* Author : OBKoro1
* Date : 2019-12-30 16:59:30
* LastEditors : OBKoro1
* LastEditTime : 2020-08-29 14:21:47
* LastEditTime : 2020-08-31 11:33:00
* FilePath : \autoCommit\src\models\commitHandle.ts
* Description : commit
* https://github.com/OBKoro1
@ -42,7 +42,6 @@ class CommitHandle {
this.paramsObj = message.data.form;
this.moreObj = message.data.moreObj;
this.timeArr = [];
console.log('seb',sep)
this.timeHandle();
this.autoCommitView = getPanelWebview();
this.userCancel = false;
@ -129,10 +128,10 @@ class CommitHandle {
try {
// 异步执行命令 让出线程 打印日志 等
commitMsg = await new Promise((resolve, reject) => {
let cmd = `cd ${this.paramsObj.itemSrc} && git add . && git commit -m '${this.paramsObj.commitMsg}' --date='${time}'`;
const cmd = `git add . && git commit -m '${this.paramsObj.commitMsg}' --date='${time}'`;
exec(cmd, {
encoding: 'utf8',
// cwd: this.paramsObj.itemSrc,
cwd: this.paramsObj.itemSrc,
env: undefined
},(error, stdout, stderr) => {
if (error) {
@ -185,10 +184,10 @@ class CommitHandle {
outputLog('提交中...');
this.autoCommitView.postMessage('提交中...', '提交中');
const res = await new Promise((resolve, reject) => {
let cmd = `cd ${this.paramsObj.itemSrc} && git pull && git push`;
const cmd = `git pull && git push`;
exec(cmd,{
encoding: 'utf8',
// cwd: this.paramsObj.itemSrc,
cwd: this.paramsObj.itemSrc,
env: undefined
},(error, stdout, stderr) => {
if (error) {
@ -211,8 +210,11 @@ class CommitHandle {
this.autoCommitView.postMessage('回滚', '回滚');
outputLog('回滚中...');
return await new Promise((resolve, reject) => {
let cmd = `cd ${this.paramsObj.itemSrc} && git reset --hard HEAD~${totalNum}`;
exec(cmd, (error, stdout, stderr) => {
const cmd = `git reset --hard HEAD~${totalNum}`;
exec(cmd,{
encoding: 'utf8',
cwd: this.paramsObj.itemSrc,
}, (error, stdout, stderr) => {
if (error) {
outputLog(`执行命令出错:${cmd}`);
outputLog(`回滚失败:${error}`, stderr);
@ -307,22 +309,6 @@ class CommitHandle {
}
return timeArr;
}
// 同步执行命令
myExecSync(cmd: string) {
// 除了该方法直到子进程完全关闭后才返回 执行完毕 返回
try {
const res = execSync(cmd, {
encoding: 'utf8',
cwd: undefined,
env: undefined
});
return res;
} catch (err) {
outputLog(`执行命令出错:${cmd}`);
outputLog(`错误信息:${err}`);
return err;
}
}
}
export default CommitHandle;

View File

@ -88,7 +88,7 @@
<span>随机commit次数 :</span>
</el-tooltip>
</label>
<el-input-number v-model="form.commitNumber" :step="1" :min="2" :max="30" size="large"></el-input-number>
<el-input-number v-model="form.commitNumber" :step="1" :min="2" :max="88" size="large"></el-input-number>
</el-form-item>
<el-form-item class="form_item" prop="commitNumber" v-else>
<label slot="label">
@ -96,7 +96,7 @@
<span>默认commit次数 :</span>
</el-tooltip>
</label>
<el-input-number v-model="form.commitNumber" :step="1" :min="1" :max="0" size="large"></el-input-number>
<el-input-number v-model="form.commitNumber" :step="1" :min="1" :max="88" size="large"></el-input-number>
</el-form-item>
<el-form-item v-for="(ele, index) in form.timeArr" :key="index" :prop="'timeArr.' + index + '.value'" :rules="{
required: true, message: '日期不能为空', trigger: 'blur'
@ -116,7 +116,7 @@
<span>该范围每天提交次数{{index+1}} :</span>
</el-tooltip>
</label>
<el-input-number v-model="ele.commitNumber" :step="1" :min="0" :max="30" ></el-input-number>
<el-input-number v-model="ele.commitNumber" :step="1" :min="0" :max="88" ></el-input-number>
<el-button @click.prevent="removeTime(index)" :disabled="form.timeArr.length === 1">删除</el-button>
</el-form-item>
<el-form-item>