25 lines
941 B
TypeScript
Raw Normal View History

2023-05-05 21:27:40 +08:00
import * as vscode from 'vscode';
import DtmWrapper from '../toolwrapper/dtm';
2023-05-10 17:56:56 +08:00
import { regInMessage, regOutMessage } from '../util/reg_messages';
2023-05-18 16:43:06 +08:00
import { runCommandAndWriteOutput } from '../util/commonUtil';
2023-05-05 21:27:40 +08:00
2023-05-10 17:56:56 +08:00
regInMessage({command: 'doCommit', content: ''});
2023-05-16 14:35:01 +08:00
export async function doCommit(message: any, panel: vscode.WebviewPanel|vscode.WebviewView): Promise<void> {
2023-05-05 21:27:40 +08:00
const dtmWrapper = new DtmWrapper();
2023-05-18 16:43:06 +08:00
const result = await runCommandAndWriteOutput('git', ['diff', '--cached'], '');
let commitResult = {status: -1, message: '', log: ''};
if ((await result).stdout === '') {
commitResult = await dtmWrapper.commitall(message.content);
} else {
commitResult = await dtmWrapper.commit(message.content);
}
2023-05-05 21:27:40 +08:00
if (commitResult.status === 0) {
vscode.window.showInformationMessage('Commit successfully.');
} else {
vscode.window.showErrorMessage(`Error commit fail: ${commitResult.message} ${commitResult.log}`);
}
return;
2023-05-18 16:43:06 +08:00
}