Skip to content

Commit f11a1ec

Browse files
authored
Merge pull request jupyterlab#20 from zzhangjii/test
Test
2 parents d370bfd + 27d2b67 commit f11a1ec

File tree

2 files changed

+124
-6
lines changed

2 files changed

+124
-6
lines changed

git_handler/hi/hi/handlers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,14 @@ def get(self):
3737
def post(self):
3838
my_data = json.loads(self.request.body)
3939
temp = my_data["git_command"]
40+
<<<<<<< HEAD
41+
print(temp)
42+
my_output = subprocess.check_output(temp)
43+
#my_output = subprocess.check_output(["git", temp])
44+
=======
4045
print(temp+"hahahaha")
4146
my_output = subprocess.check_output(["git", temp])
47+
>>>>>>> 031de4ba54da64ac3661b65f1352829178560f03
4248
self.finish(my_output)
4349
#self.finish(json.dumps(post_metrics()))
4450
print("Hi there! post extensions!!")

src/index.ts

Lines changed: 118 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,21 @@ namespace CommandIDs {
5252
export
5353
const git_st = 'AVCbox:git status';
5454

55+
export
56+
const git_add = 'AVCbox:git add';
57+
5558
export
5659
const git_log = 'AVCbox:git log';
5760

5861
export
5962
const git_pull = 'AVCbox:git pull';
6063

64+
export
65+
const git_remote = 'AVCbox:git remote';
66+
67+
export
68+
const git_commit = 'AVCbox:git commit';
69+
6170
export
6271
const get_git_api = 'AVCbox:git api';
6372
};
@@ -79,6 +88,72 @@ const AVCboxPlugin: JupyterLabPlugin<void> = {
7988
*/
8089
export default AVCboxPlugin;
8190

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+
82157
/**
83158
* a test link function for buttons
84159
*/
@@ -103,6 +178,7 @@ function loadGapi(): Promise<void> {
103178
}
104179

105180
function POST_Git_Request(git_command){
181+
let data0 = {"git_command":git_command , "parameters":{"id":"valore"}};
106182
let request = {
107183
url: URLExt.join(serverSettings.baseUrl, 'hi'),
108184
method: 'POST',
@@ -111,15 +187,16 @@ function POST_Git_Request(git_command){
111187
headers: {
112188
foo: 'bar'
113189
},
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"}}'
116192
};
117193

118194
ServerConnection.makeRequest(request, serverSettings).then(response =>{
119195
if (response.xhr.status !== 200) {
120196
throw ServerConnection.makeError(response);
121197
}
122-
console.log(JSON.stringify(response.data, null, 2));
198+
//console.log(JSON.stringify(response.data, null, 2));
199+
console.log(response.data);
123200
});
124201

125202
}
@@ -143,6 +220,7 @@ function activateAVCbox(app: JupyterLab, rendermime: IRenderMime, palette: IComm
143220
rendermime: rendermime.clone(),
144221
contentFactory
145222
});
223+
146224
//test msg
147225
console.log('JupyterLab extension JL_git (typescript extension) is activated!');
148226
// Add the AVCbox panel to the tracker.
@@ -157,7 +235,7 @@ function activateAVCbox(app: JupyterLab, rendermime: IRenderMime, palette: IComm
157235
label: 'git status command',
158236
execute: args => {
159237
console.log('Try to exec *git status* command');
160-
POST_Git_Request("status")
238+
POST_Git_Request( ["git","status"] )
161239
}
162240
});
163241
palette.addItem({ command, category });
@@ -175,7 +253,7 @@ function activateAVCbox(app: JupyterLab, rendermime: IRenderMime, palette: IComm
175253
console.log(data['limits']['memory']);
176254
//console.log(JSON.stringify(data, null, 2));
177255
});
178-
POST_Git_Request("log")
256+
POST_Git_Request(["git","log"])
179257
}
180258
});
181259
palette.addItem({ command, category });
@@ -186,7 +264,41 @@ function activateAVCbox(app: JupyterLab, rendermime: IRenderMime, palette: IComm
186264
label: 'git pull command',
187265
execute: args => {
188266
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"])
190302
}
191303
});
192304
palette.addItem({ command, category });

0 commit comments

Comments
 (0)