@@ -6,8 +6,10 @@ import { Panel } from 'src/panel';
66import { IFileNode , MRTreeDataProvider } from 'src/tree/mrTree' ;
77import { ReleaseTreeDataProvider } from 'src/tree/releaseTree' ;
88import { IRepoInfo , IMRWebViewDetail } from 'src/typings/commonTypes' ;
9+ import { GitService } from 'src/common/gitService' ;
910
1011export async function activate ( context : vscode . ExtensionContext ) {
12+ await GitService . init ( ) ;
1113 const repoInfo = await CodingServer . getRepoParams ( ) ;
1214
1315 if ( ! repoInfo ?. team ) {
@@ -32,7 +34,7 @@ export async function activate(context: vscode.ExtensionContext) {
3234
3335 const mrDataProvider = new MRTreeDataProvider ( context , codingSrv ) ;
3436 const releaseDataProvider = new ReleaseTreeDataProvider ( context ) ;
35- vscode . window . createTreeView ( `mrTreeView` , {
37+ const mrTree = vscode . window . createTreeView ( `mrTreeView` , {
3638 treeDataProvider : mrDataProvider ,
3739 showCollapseAll : true ,
3840 } ) ;
@@ -79,6 +81,58 @@ export async function activate(context: vscode.ExtensionContext) {
7981 mrDataProvider . refresh ( ) ;
8082 } ) ,
8183 ) ;
84+ context . subscriptions . push (
85+ vscode . commands . registerCommand ( 'codingPlugin.newMrDesc' , async ( ) => {
86+ const doc = await vscode . workspace . openTextDocument ( {
87+ language : `markdown` ,
88+ } ) ;
89+ await vscode . window . showTextDocument ( doc ) ;
90+ } ) ,
91+ ) ;
92+ context . subscriptions . push (
93+ vscode . commands . registerCommand ( 'codingPlugin.createMr' , async ( ) => {
94+ const editor = vscode . window . activeTextEditor ;
95+ if ( ! editor ) {
96+ return ;
97+ }
98+
99+ const content = editor . document . getText ( ) ;
100+ if ( ! content ) {
101+ return ;
102+ }
103+
104+ const { data } = await codingSrv . getBranchList ( ) ;
105+ const list = data . map ( ( i ) => ( {
106+ label : i . name ,
107+ description : `` ,
108+ } ) ) ;
109+ const src = await vscode . window . showQuickPick ( list , {
110+ placeHolder : `Please choose source branch` ,
111+ } ) ;
112+ if ( ! src ) return ;
113+ const des = await vscode . window . showQuickPick ( list , {
114+ placeHolder : `Please choose target branch` ,
115+ } ) ;
116+ if ( ! des ) return ;
117+ const title = await vscode . window . showInputBox ( { placeHolder : `Please input title` } ) ;
118+ if ( ! title ) {
119+ return ;
120+ }
121+
122+ try {
123+ const newMr = await codingSrv . createMR ( {
124+ content,
125+ title,
126+ srcBranch : src . label ,
127+ desBranch : des . label ,
128+ } ) ;
129+ vscode . window . showInformationMessage (
130+ `Merge request ${ newMr . data . merge_request . title } was created successfully.` ,
131+ ) ;
132+ mrDataProvider . refresh ( ) ;
133+ } catch ( err ) { }
134+ } ) ,
135+ ) ;
82136 context . subscriptions . push (
83137 vscode . commands . registerCommand ( 'codingPlugin.switchRepo' , async ( ) => {
84138 try {
@@ -131,5 +185,4 @@ export async function activate(context: vscode.ExtensionContext) {
131185 }
132186}
133187
134- export function deactivate ( ) {
135- }
188+ export function deactivate ( ) { }
0 commit comments