Skip to content

Commit 1a9c004

Browse files
committed
Set status 500 when git commands fail
1 parent 1233099 commit 1a9c004

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

jupyterlab_git/handlers.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ async def post(self):
4747
response = await self.git.clone(
4848
data["current_path"], data["clone_url"], data.get("auth", None)
4949
)
50+
51+
if response["code"] != 0:
52+
self.set_status(500)
5053
self.finish(json.dumps(response))
5154

5255

@@ -72,6 +75,7 @@ async def post(self):
7275

7376
show_top_level = await self.git.show_top_level(current_path)
7477
if show_top_level["code"] != 0:
78+
self.set_status(500)
7579
self.finish(json.dumps(show_top_level))
7680
else:
7781
branch = await self.git.branch(current_path)
@@ -103,6 +107,9 @@ async def post(self):
103107
"""
104108
current_path = self.get_json_body()["current_path"]
105109
result = await self.git.show_top_level(current_path)
110+
111+
if result["code"] != 0:
112+
self.set_status(500)
106113
self.finish(json.dumps(result))
107114

108115

@@ -121,6 +128,9 @@ async def post(self):
121128
"""
122129
current_path = self.get_json_body()["current_path"]
123130
result = await self.git.show_prefix(current_path)
131+
132+
if result["code"] != 0:
133+
self.set_status(500)
124134
self.finish(json.dumps(result))
125135

126136

@@ -136,6 +146,9 @@ async def post(self):
136146
"""
137147
current_path = self.get_json_body()["current_path"]
138148
result = await self.git.status(current_path)
149+
150+
if result["code"] != 0:
151+
self.set_status(500)
139152
self.finish(json.dumps(result))
140153

141154

@@ -155,6 +168,9 @@ async def post(self):
155168
current_path = body["current_path"]
156169
history_count = body.get("history_count", 25)
157170
result = await self.git.log(current_path, history_count)
171+
172+
if result["code"] != 0:
173+
self.set_status(500)
158174
self.finish(json.dumps(result))
159175

160176

@@ -194,6 +210,9 @@ async def post(self):
194210
"""
195211
top_repo_path = self.get_json_body()["top_repo_path"]
196212
my_output = await self.git.diff(top_repo_path)
213+
214+
if my_output["code"] != 0:
215+
self.set_status(500)
197216
self.finish(my_output)
198217

199218

@@ -556,6 +575,9 @@ class GitChangedFilesHandler(GitHandler):
556575
@web.authenticated
557576
async def post(self):
558577
body = await self.git.changed_files(**self.get_json_body())
578+
579+
if body["code"] != 0:
580+
self.set_status(500)
559581
self.finish(json.dumps(body))
560582

561583

0 commit comments

Comments
 (0)