mirror of
https://github.com/OBKoro1/autoCommit.git
synced 2024-11-24 19:39:23 +08:00
1.0.0
This commit is contained in:
parent
551562c9ff
commit
77facfe79f
@ -14,4 +14,4 @@
|
||||
|
||||
### [V1.0.0]
|
||||
|
||||
- Initial release
|
||||
插件开源
|
||||
|
BIN
images/autoCommit.gif
Normal file
BIN
images/autoCommit.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.4 MiB |
BIN
images/commit-color.png
Normal file
BIN
images/commit-color.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
@ -2,7 +2,7 @@
|
||||
* Author : OBKoro1
|
||||
* Date : 2019-12-30 16:59:30
|
||||
* LastEditors : OBKoro1
|
||||
* LastEditTime : 2020-01-07 22:30:03
|
||||
* LastEditTime : 2020-01-08 10:48:40
|
||||
* FilePath : /autoCommit/src/models/commitHandle.ts
|
||||
* Description : commit 具体操作
|
||||
* https://github.com/OBKoro1
|
||||
@ -13,7 +13,12 @@ import * as moment from 'moment';
|
||||
import * as fs from 'fs';
|
||||
import { execSync, exec } from 'child_process';
|
||||
import { RandomNumber } from '../util/util';
|
||||
import { getPanelWebview, outputLog, isProduction } from '../util/vscodeUtil';
|
||||
import {
|
||||
getPanelWebview,
|
||||
outputLog,
|
||||
isProduction,
|
||||
getExtensionContext
|
||||
} from '../util/vscodeUtil';
|
||||
import WebView from './WebView';
|
||||
|
||||
interface timeElement {
|
||||
@ -149,7 +154,7 @@ class CommitHandle {
|
||||
if (this.cancelCommit()) {
|
||||
if (totalNum < 1) return;
|
||||
outputLog('回滚中...');
|
||||
const res = await new Promise((resolve, reject) => {
|
||||
await new Promise((resolve, reject) => {
|
||||
let cmd = `cd ${this.paramsObj.itemSrc} && git reset --hard HEAD~${totalNum}`;
|
||||
exec(cmd, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
@ -164,6 +169,7 @@ class CommitHandle {
|
||||
});
|
||||
} else {
|
||||
outputLog('提交中...');
|
||||
this.autoCommitView.postMessage('提交中...', '提交中');
|
||||
const res = await new Promise((resolve, reject) => {
|
||||
let cmd = `cd ${this.paramsObj.itemSrc} && git pull && git push`;
|
||||
exec(cmd, (error, stdout, stderr) => {
|
||||
@ -182,8 +188,10 @@ class CommitHandle {
|
||||
}
|
||||
commitEnd(totalNum: number) {
|
||||
this.userCancel = false; // 重新打开终止开关
|
||||
this.autoCommitView.postMessage('commit 完成', 'commit 完成');
|
||||
this.autoCommitView.postMessage('commit 完成', this.paramsObj);
|
||||
getExtensionContext().globalState.update('commit-params', this.paramsObj);
|
||||
outputLog('自动commit完成', `总commit次数${totalNum}`);
|
||||
outputLog('保存参数信息');
|
||||
}
|
||||
cancelCommit() {
|
||||
if (this.userCancel) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Author : OBKoro1
|
||||
* Date : 2019-12-25 17:08:18
|
||||
* @LastEditors : OBKoro1
|
||||
* @LastEditTime : 2020-01-02 21:49:13
|
||||
* LastEditors : OBKoro1
|
||||
* LastEditTime : 2020-01-08 10:04:53
|
||||
* FilePath : /autoCommit/src/models/index.ts
|
||||
* Description : 插件逻辑入口
|
||||
* https://github.com/OBKoro1
|
||||
@ -39,6 +39,9 @@ class ExtensionLogic {
|
||||
};
|
||||
this.autoCommitView.create(option);
|
||||
this.autoCommitView.postMessage('isProduction', isProduction());
|
||||
const formData = this.context.globalState.get('commit-params')
|
||||
this.autoCommitView.postMessage('init-formData', formData)
|
||||
|
||||
}
|
||||
// 处理webview的消息
|
||||
private messageCallBack(message: webviewMsg) {
|
||||
|
@ -2,14 +2,14 @@
|
||||
* Author : OBKoro1
|
||||
* Date : 2019-12-25 17:13:30
|
||||
* LastEditors : OBKoro1
|
||||
* LastEditTime : 2020-01-02 13:44:30
|
||||
* LastEditTime : 2020-01-08 09:59:48
|
||||
* FilePath : /autoCommit/src/util/vscodeUtil.ts
|
||||
* Description : vscode 相关的公共方法
|
||||
* https://github.com/OBKoro1
|
||||
*/
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
let extensionContext = '';
|
||||
let extensionContext: vscode.ExtensionContext;
|
||||
let webview: any;
|
||||
|
||||
// 存储插件上下午文
|
||||
@ -18,7 +18,7 @@ function setExtensionContext(context: any) {
|
||||
}
|
||||
|
||||
// 获取插件上下文
|
||||
function getExtensionContext() {
|
||||
function getExtensionContext(): vscode.ExtensionContext {
|
||||
return extensionContext;
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ function outputLog(...arr: any) {
|
||||
|
||||
// 是否生产环境
|
||||
function isProduction() {
|
||||
return process.env.NODE_ENV === 'production' // production时 为打包安装版本
|
||||
return process.env.NODE_ENV === 'production'; // production时 为打包安装版本
|
||||
}
|
||||
|
||||
// vscode 消息通知
|
||||
|
@ -131,7 +131,7 @@
|
||||
</el-form-item>
|
||||
<div class="tip">觉得这个插件还不错的话, 请给我点个<el-link href="https://github.com/OBKoro1/autoCommit" type="primary" target="_blank">Star⭐️</el-link>吧~</div>
|
||||
<div v-if="!isProduction">
|
||||
<div>{{ showText.logArr }}</div>
|
||||
<div>{{ form }}</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
@ -173,9 +173,8 @@
|
||||
command: [],
|
||||
data: []
|
||||
},
|
||||
runNow: 0, // 0 初始化 1运行中 2运行结束 3取消运行
|
||||
runNow: 0, // 0 初始化 1运行中 2运行结束 3取消运行 4push中
|
||||
form: {
|
||||
// TODO: 保存其他几个参数
|
||||
// itemSrc: '/Users/koro/work/web_my/testCommit',
|
||||
randomCommit: true,
|
||||
itemSrc: '点击选择要commit的项目文件夹',
|
||||
@ -269,7 +268,17 @@
|
||||
const { command, data } = event.data;
|
||||
this.showText.command.unshift(command)
|
||||
this.showText.data.unshift(data)
|
||||
if (command === 'choose item success') {
|
||||
if(command === 'init-formData'){
|
||||
if (data) {
|
||||
this.form = data
|
||||
// this.form.timeArr = [
|
||||
// {
|
||||
// value: '',
|
||||
// commitNumber: 0
|
||||
// }
|
||||
// ]
|
||||
}
|
||||
} else if (command === 'choose item success') {
|
||||
// 选择文件夹成功
|
||||
this.form.itemSrc = data
|
||||
}else if(command === 'choose item error'){
|
||||
@ -279,7 +288,9 @@
|
||||
message: `${data}根目录没有.git文件夹`,
|
||||
duration: 0
|
||||
});
|
||||
} else if(command === 'commit 完成'){
|
||||
} else if(command === ''){
|
||||
|
||||
}else if(command === 'commit 完成'){
|
||||
// commit 完成
|
||||
this.runNow = 2
|
||||
} else if(command === 'console-log'){
|
||||
|
Loading…
Reference in New Issue
Block a user