@@ -52,9 +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
61
+ export
62
+ const git_pull = 'AVCbox:git pull' ;
63
+
64
+ export
65
+ const git_remote = 'AVCbox:git remote' ;
66
+
67
+ export
68
+ const git_commit = 'AVCbox:git commit' ;
69
+
58
70
export
59
71
const get_git_api = 'AVCbox:git api' ;
60
72
} ;
@@ -76,10 +88,77 @@ const AVCboxPlugin: JupyterLabPlugin<void> = {
76
88
*/
77
89
export default AVCboxPlugin ;
78
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
+
79
157
/**
80
158
* a test link function for buttons
81
159
*/
82
160
161
+
83
162
let serverSettings = ServerConnection . makeSettings ( ) ;
84
163
let gapiLoaded = new PromiseDelegate < void > ( ) ;
85
164
export
@@ -98,6 +177,29 @@ function loadGapi(): Promise<void> {
98
177
} ) ;
99
178
}
100
179
180
+ function POST_Git_Request ( git_command ) {
181
+ let data0 = { "git_command" :git_command , "parameters" :{ "id" :"valore" } } ;
182
+ let request = {
183
+ url : URLExt . join ( serverSettings . baseUrl , 'hi' ) ,
184
+ method : 'POST' ,
185
+ cache : true ,
186
+ contentType : 'bar' ,
187
+ headers : {
188
+ foo : 'bar'
189
+ } ,
190
+ data : JSON . stringify ( data0 ) ,
191
+ //data: '{"git_command":["git", "status"], "parameters":{"id":"valore"}}'
192
+ } ;
193
+
194
+ ServerConnection . makeRequest ( request , serverSettings ) . then ( response => {
195
+ if ( response . xhr . status !== 200 ) {
196
+ throw ServerConnection . makeError ( response ) ;
197
+ }
198
+ //console.log(JSON.stringify(response.data, null, 2));
199
+ console . log ( response . data ) ;
200
+ } ) ;
201
+
202
+ }
101
203
102
204
/**
103
205
* Activate the AVCbox extension.
@@ -118,6 +220,7 @@ function activateAVCbox(app: JupyterLab, rendermime: IRenderMime, palette: IComm
118
220
rendermime : rendermime . clone ( ) ,
119
221
contentFactory
120
222
} ) ;
223
+
121
224
//test msg
122
225
console . log ( 'JupyterLab extension JL_git (typescript extension) is activated!' ) ;
123
226
// Add the AVCbox panel to the tracker.
@@ -132,24 +235,7 @@ function activateAVCbox(app: JupyterLab, rendermime: IRenderMime, palette: IComm
132
235
label : 'git status command' ,
133
236
execute : args => {
134
237
console . log ( 'Try to exec *git status* command' ) ;
135
-
136
- let request = {
137
- url : URLExt . join ( serverSettings . baseUrl , 'hi' ) ,
138
- method : 'POST' ,
139
- cache : true ,
140
- contentType : 'bar' ,
141
- headers : {
142
- foo : 'bar'
143
- } ,
144
- data : '["foo", {"bar":["baz", null, 1.0, 2]}]' ,
145
- } ;
146
-
147
- ServerConnection . makeRequest ( request , serverSettings ) . then ( response => {
148
- if ( response . xhr . status !== 200 ) {
149
- throw ServerConnection . makeError ( response ) ;
150
- }
151
- console . log ( JSON . stringify ( response . data , null , 2 ) ) ;
152
- } ) ;
238
+ POST_Git_Request ( [ "git" , "status" ] )
153
239
}
154
240
} ) ;
155
241
palette . addItem ( { command, category } ) ;
@@ -161,17 +247,63 @@ function activateAVCbox(app: JupyterLab, rendermime: IRenderMime, palette: IComm
161
247
label : 'git log command' ,
162
248
execute : args => {
163
249
console . log ( 'Try to exec *git log* command' ) ;
250
+
164
251
$ . getJSON ( serverSettings . baseUrl + 'hi' , function ( data ) {
165
- // console.log(data['rss']);
166
- // console.log(data['limits']['memory']);
167
- console . log ( JSON . stringify ( data , null , 2 ) ) ;
252
+ console . log ( data [ 'rss' ] ) ;
253
+ console . log ( data [ 'limits' ] [ 'memory' ] ) ;
254
+ // console.log(JSON.stringify(data, null, 2));
168
255
} ) ;
256
+ POST_Git_Request ( [ "git" , "log" ] )
257
+ }
258
+ } ) ;
259
+ palette . addItem ( { command, category } ) ;
260
+
261
+ //git pull button
262
+ command = CommandIDs . git_pull ;
263
+ commands . addCommand ( command , {
264
+ label : 'git pull command' ,
265
+ execute : args => {
266
+ console . log ( 'Try to exec *git pull* command' ) ;
267
+ POST_Git_Request ( [ "git" , "pull" ] )
169
268
}
170
269
} ) ;
171
270
palette . addItem ( { command, category } ) ;
172
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" ] )
302
+ }
303
+ } ) ;
304
+ palette . addItem ( { command, category } ) ;
173
305
174
- //Third button
306
+ //test button
175
307
command = CommandIDs . get_git_api ;
176
308
commands . addCommand ( command , {
177
309
label : 'Access GitHub JSON' ,
0 commit comments