@@ -52,12 +52,21 @@ namespace CommandIDs {
52
52
export
53
53
const git_st = 'AVCbox:git status' ;
54
54
55
+ export
56
+ const git_add = 'AVCbox:git add' ;
57
+
55
58
export
56
59
const git_log = 'AVCbox:git log' ;
57
60
58
61
export
59
62
const git_pull = 'AVCbox:git pull' ;
60
63
64
+ export
65
+ const git_remote = 'AVCbox:git remote' ;
66
+
67
+ export
68
+ const git_commit = 'AVCbox:git commit' ;
69
+
61
70
export
62
71
const get_git_api = 'AVCbox:git api' ;
63
72
} ;
@@ -79,6 +88,72 @@ const AVCboxPlugin: JupyterLabPlugin<void> = {
79
88
*/
80
89
export default AVCboxPlugin ;
81
90
91
+ /**
92
+ * Export interfaces for Git command use
93
+ */
94
+ export interface IGit {
95
+ path : string ;
96
+ version : string ;
97
+ }
98
+
99
+ export interface IFileStatus {
100
+ x : string ;
101
+ y : string ;
102
+ path : string ;
103
+ rename ?: string ;
104
+ }
105
+
106
+ export interface Remote {
107
+ name : string ;
108
+ url : string ;
109
+ }
110
+
111
+ export enum RefType {
112
+ Head ,
113
+ RemoteHead ,
114
+ Tag
115
+ }
116
+
117
+ export interface Ref {
118
+ type : RefType ;
119
+ name ?: string ;
120
+ commit ?: string ;
121
+ remote ?: string ;
122
+ }
123
+
124
+ export interface Branch extends Ref {
125
+ upstream ?: string ;
126
+ ahead ?: number ;
127
+ behind ?: number ;
128
+ }
129
+
130
+ export interface IExecutionResult {
131
+ exitCode : number ;
132
+ stdout : string ;
133
+ stderr : string ;
134
+ }
135
+
136
+ export interface IGitErrorData {
137
+ error ?: Error ;
138
+ message ?: string ;
139
+ stdout ?: string ;
140
+ stderr ?: string ;
141
+ exitCode ?: number ;
142
+ gitErrorCode ?: string ;
143
+ gitCommand ?: string ;
144
+ }
145
+
146
+ export interface IGitOptions {
147
+ gitPath : string ;
148
+ version : string ;
149
+ env ?: any ;
150
+ }
151
+
152
+ export interface Commit {
153
+ hash : string ;
154
+ message : string ;
155
+ }
156
+
82
157
/**
83
158
* a test link function for buttons
84
159
*/
@@ -103,6 +178,7 @@ function loadGapi(): Promise<void> {
103
178
}
104
179
105
180
function POST_Git_Request ( git_command ) {
181
+ let data0 = { "git_command" :git_command , "parameters" :{ "id" :"valore" } } ;
106
182
let request = {
107
183
url : URLExt . join ( serverSettings . baseUrl , 'hi' ) ,
108
184
method : 'POST' ,
@@ -111,15 +187,16 @@ function POST_Git_Request(git_command){
111
187
headers : {
112
188
foo : 'bar'
113
189
} ,
114
- // data: '["foo", {"bar":["git status", null, 1.0, 2]}]' ,
115
- data : '{"git_command":"' + git_command + '" , "parameters":{"id":"valore"}}'
190
+ data : JSON . stringify ( data0 ) ,
191
+ // data: '{"git_command":["git", "status"] , "parameters":{"id":"valore"}}'
116
192
} ;
117
193
118
194
ServerConnection . makeRequest ( request , serverSettings ) . then ( response => {
119
195
if ( response . xhr . status !== 200 ) {
120
196
throw ServerConnection . makeError ( response ) ;
121
197
}
122
- console . log ( JSON . stringify ( response . data , null , 2 ) ) ;
198
+ //console.log(JSON.stringify(response.data, null, 2));
199
+ console . log ( response . data ) ;
123
200
} ) ;
124
201
125
202
}
@@ -143,6 +220,7 @@ function activateAVCbox(app: JupyterLab, rendermime: IRenderMime, palette: IComm
143
220
rendermime : rendermime . clone ( ) ,
144
221
contentFactory
145
222
} ) ;
223
+
146
224
//test msg
147
225
console . log ( 'JupyterLab extension JL_git (typescript extension) is activated!' ) ;
148
226
// Add the AVCbox panel to the tracker.
@@ -157,7 +235,7 @@ function activateAVCbox(app: JupyterLab, rendermime: IRenderMime, palette: IComm
157
235
label : 'git status command' ,
158
236
execute : args => {
159
237
console . log ( 'Try to exec *git status* command' ) ;
160
- POST_Git_Request ( " status")
238
+ POST_Git_Request ( [ "git" , " status"] )
161
239
}
162
240
} ) ;
163
241
palette . addItem ( { command, category } ) ;
@@ -175,7 +253,7 @@ function activateAVCbox(app: JupyterLab, rendermime: IRenderMime, palette: IComm
175
253
console . log ( data [ 'limits' ] [ 'memory' ] ) ;
176
254
//console.log(JSON.stringify(data, null, 2));
177
255
} ) ;
178
- POST_Git_Request ( " log")
256
+ POST_Git_Request ( [ "git" , " log"] )
179
257
}
180
258
} ) ;
181
259
palette . addItem ( { command, category } ) ;
@@ -186,7 +264,41 @@ function activateAVCbox(app: JupyterLab, rendermime: IRenderMime, palette: IComm
186
264
label : 'git pull command' ,
187
265
execute : args => {
188
266
console . log ( 'Try to exec *git pull* command' ) ;
189
- POST_Git_Request ( "pull" )
267
+ POST_Git_Request ( [ "git" , "pull" ] )
268
+ }
269
+ } ) ;
270
+ palette . addItem ( { command, category } ) ;
271
+
272
+ //git remote button
273
+ command = CommandIDs . git_remote ;
274
+ commands . addCommand ( command , {
275
+ label : 'git remote command' ,
276
+ execute : args => {
277
+ console . log ( 'Try to exec *git remote -v* command' ) ;
278
+ POST_Git_Request ( [ "git" , "remote" , "-v" ] )
279
+ }
280
+ } ) ;
281
+ palette . addItem ( { command, category } ) ;
282
+
283
+ //jvftcf
284
+ //git commit button
285
+ command = CommandIDs . git_commit ;
286
+ commands . addCommand ( command , {
287
+ label : 'git commit command' ,
288
+ execute : args => {
289
+ console . log ( 'Try to exec *git commit* command' ) ;
290
+ POST_Git_Request ( [ "git" , "commit" , "-m" , "'surprise!!!!'" ] )
291
+ }
292
+ } ) ;
293
+ palette . addItem ( { command, category } ) ;
294
+
295
+ //git add button
296
+ command = CommandIDs . git_add ;
297
+ commands . addCommand ( command , {
298
+ label : 'git add command' ,
299
+ execute : args => {
300
+ console . log ( 'Try to exec *git add* command' ) ;
301
+ POST_Git_Request ( [ "git" , "add" , "src/index.ts" ] )
190
302
}
191
303
} ) ;
192
304
palette . addItem ( { command, category } ) ;
0 commit comments