mirror of
https://github.com/OBKoro1/autoCommit.git
synced 2024-11-22 10:29:23 +08:00
随机commit次数以及commit回滚
This commit is contained in:
parent
8bf8eb9b92
commit
551562c9ff
@ -6,6 +6,12 @@
|
|||||||
<!-- TODO: npm包形式 -->
|
<!-- TODO: npm包形式 -->
|
||||||
<!-- webview 的icon -->
|
<!-- webview 的icon -->
|
||||||
|
|
||||||
|
<!-- TODO: 支持谷歌插件 -->
|
||||||
|
<!-- TODO: html的链接 -->
|
||||||
|
|
||||||
|
<!-- TODO: commit的颜色 -->
|
||||||
|
|
||||||
|
|
||||||
### [V1.0.0]
|
### [V1.0.0]
|
||||||
|
|
||||||
- Initial release
|
- Initial release
|
@ -2,6 +2,4 @@
|
|||||||
|
|
||||||
# 用于学习交流
|
# 用于学习交流
|
||||||
|
|
||||||
<!-- TODO: html的链接 -->
|
|
||||||
|
|
||||||
<!-- TODO: commit的颜色 -->
|
|
@ -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-04 15:14:39
|
* LastEditTime : 2020-01-07 22:30:03
|
||||||
* FilePath : /autoCommit/src/models/commitHandle.ts
|
* FilePath : /autoCommit/src/models/commitHandle.ts
|
||||||
* Description : commit 具体操作
|
* Description : commit 具体操作
|
||||||
* https://github.com/OBKoro1
|
* https://github.com/OBKoro1
|
||||||
@ -91,6 +91,10 @@ class CommitHandle {
|
|||||||
if (this.cancelCommit()) break;
|
if (this.cancelCommit()) break;
|
||||||
// 每个日期commit次数
|
// 每个日期commit次数
|
||||||
let dayCommitNumber = this.paramsObj.commitNumber;
|
let dayCommitNumber = this.paramsObj.commitNumber;
|
||||||
|
if (this.paramsObj.randomCommit) {
|
||||||
|
// 随机commit次数
|
||||||
|
dayCommitNumber = RandomNumber(1, this.paramsObj.commitNumber);
|
||||||
|
}
|
||||||
if (item.commitNumber !== 0) {
|
if (item.commitNumber !== 0) {
|
||||||
// 如果该范围有commit次数 则用该范围的
|
// 如果该范围有commit次数 则用该范围的
|
||||||
dayCommitNumber = item.commitNumber;
|
dayCommitNumber = item.commitNumber;
|
||||||
@ -137,12 +141,43 @@ class CommitHandle {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
await outputLog(`${totalNum + 1}commit内容`, commitContent);
|
outputLog(`${totalNum + 1}commit内容`, commitContent);
|
||||||
await outputLog(`${totalNum + 1}commit信息`, commitMsg);
|
outputLog(`${totalNum + 1}commit信息`, commitMsg);
|
||||||
totalNum++;
|
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);
|
this.commitEnd(totalNum);
|
||||||
}
|
}
|
||||||
commitEnd(totalNum: number) {
|
commitEnd(totalNum: number) {
|
||||||
|
@ -44,12 +44,33 @@
|
|||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item class="form_item" prop="commitNumber">
|
<el-form-item class="form_item" prop="commitNumber">
|
||||||
|
<label slot="label">
|
||||||
|
<el-tooltip class="item" content="时间范围内默认每个日期是否随机commit" placement="top-start">
|
||||||
|
<span>是否随机commit :</span>
|
||||||
|
</el-tooltip>
|
||||||
|
</label>
|
||||||
|
<el-switch
|
||||||
|
@change="switchChange"
|
||||||
|
v-model="form.randomCommit"
|
||||||
|
active-color="#13ce66"
|
||||||
|
inactive-color="#ff4949">
|
||||||
|
</el-switch>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item class="form_item" prop="commitNumber" v-if="form.randomCommit">
|
||||||
|
<label slot="label">
|
||||||
|
<el-tooltip class="item" :content="`时间范围内默认每个日期随机commit 1次~${form.commitNumber}次`" placement="top-start">
|
||||||
|
<span>随机commit次数 :</span>
|
||||||
|
</el-tooltip>
|
||||||
|
</label>
|
||||||
|
<el-input-number v-model="form.commitNumber" :step="1" :min="2" :max="20" size="large"></el-input-number>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item class="form_item" prop="commitNumber" v-else>
|
||||||
<label slot="label">
|
<label slot="label">
|
||||||
<el-tooltip class="item" content="时间范围内默认每个日期需要commit的次数" placement="top-start">
|
<el-tooltip class="item" content="时间范围内默认每个日期需要commit的次数" placement="top-start">
|
||||||
<span>默认commit次数 :</span>
|
<span>默认commit次数 :</span>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</label>
|
</label>
|
||||||
<el-input-number v-model="form.commitNumber" :step="1" :min="1" :max="100" size="large"></el-input-number>
|
<el-input-number v-model="form.commitNumber" :step="1" :min="1" :max="20" size="large"></el-input-number>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-for="(ele, index) in form.timeArr" :key="index" :prop="'timeArr.' + index + '.value'" :rules="{
|
<el-form-item v-for="(ele, index) in form.timeArr" :key="index" :prop="'timeArr.' + index + '.value'" :rules="{
|
||||||
required: true, message: '日期不能为空', trigger: 'blur'
|
required: true, message: '日期不能为空', trigger: 'blur'
|
||||||
@ -69,7 +90,7 @@
|
|||||||
<span>该范围每天提交次数{{index+1}} :</span>
|
<span>该范围每天提交次数{{index+1}} :</span>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</label>
|
</label>
|
||||||
<el-input-number v-model="ele.commitNumber" :step="1" :min="0" :max="100" ></el-input-number>
|
<el-input-number v-model="ele.commitNumber" :step="1" :min="0" :max="30" ></el-input-number>
|
||||||
<el-button @click.prevent="removeTime(index)" :disabled="form.timeArr.length === 1">删除</el-button>
|
<el-button @click.prevent="removeTime(index)" :disabled="form.timeArr.length === 1">删除</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
@ -156,6 +177,7 @@
|
|||||||
form: {
|
form: {
|
||||||
// TODO: 保存其他几个参数
|
// TODO: 保存其他几个参数
|
||||||
// itemSrc: '/Users/koro/work/web_my/testCommit',
|
// itemSrc: '/Users/koro/work/web_my/testCommit',
|
||||||
|
randomCommit: true,
|
||||||
itemSrc: '点击选择要commit的项目文件夹',
|
itemSrc: '点击选择要commit的项目文件夹',
|
||||||
fileName: 'commit.md',
|
fileName: 'commit.md',
|
||||||
commitMsg: 'autoCommit',
|
commitMsg: 'autoCommit',
|
||||||
@ -165,7 +187,7 @@
|
|||||||
commitNumber: 0
|
commitNumber: 0
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
commitNumber: 1,
|
commitNumber: 10,
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
'itemSrc': [
|
'itemSrc': [
|
||||||
@ -326,6 +348,13 @@
|
|||||||
commitNumber: 0
|
commitNumber: 0
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
switchChange(value){
|
||||||
|
if(value){
|
||||||
|
this.form.commitNumber = 10;
|
||||||
|
}else{
|
||||||
|
this.form.commitNumber = 1;
|
||||||
|
}
|
||||||
|
},
|
||||||
fileNameChange(value) {
|
fileNameChange(value) {
|
||||||
if (value === '') {
|
if (value === '') {
|
||||||
this.form.fileName = 'commit.md'
|
this.form.fileName = 'commit.md'
|
||||||
|
Loading…
Reference in New Issue
Block a user