Skip to content

Commit

Permalink
Set status 500 when git commands fail
Browse files Browse the repository at this point in the history
  • Loading branch information
fcollonval committed Oct 24, 2020
1 parent 1233099 commit 1a9c004
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions jupyterlab_git/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ async def post(self):
response = await self.git.clone(
data["current_path"], data["clone_url"], data.get("auth", None)
)

if response["code"] != 0:
self.set_status(500)
self.finish(json.dumps(response))


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

show_top_level = await self.git.show_top_level(current_path)
if show_top_level["code"] != 0:
self.set_status(500)
self.finish(json.dumps(show_top_level))
else:
branch = await self.git.branch(current_path)
Expand Down Expand Up @@ -103,6 +107,9 @@ async def post(self):
"""
current_path = self.get_json_body()["current_path"]
result = await self.git.show_top_level(current_path)

if result["code"] != 0:
self.set_status(500)
self.finish(json.dumps(result))


Expand All @@ -121,6 +128,9 @@ async def post(self):
"""
current_path = self.get_json_body()["current_path"]
result = await self.git.show_prefix(current_path)

if result["code"] != 0:
self.set_status(500)
self.finish(json.dumps(result))


Expand All @@ -136,6 +146,9 @@ async def post(self):
"""
current_path = self.get_json_body()["current_path"]
result = await self.git.status(current_path)

if result["code"] != 0:
self.set_status(500)
self.finish(json.dumps(result))


Expand All @@ -155,6 +168,9 @@ async def post(self):
current_path = body["current_path"]
history_count = body.get("history_count", 25)
result = await self.git.log(current_path, history_count)

if result["code"] != 0:
self.set_status(500)
self.finish(json.dumps(result))


Expand Down Expand Up @@ -194,6 +210,9 @@ async def post(self):
"""
top_repo_path = self.get_json_body()["top_repo_path"]
my_output = await self.git.diff(top_repo_path)

if my_output["code"] != 0:
self.set_status(500)
self.finish(my_output)


Expand Down Expand Up @@ -556,6 +575,9 @@ class GitChangedFilesHandler(GitHandler):
@web.authenticated
async def post(self):
body = await self.git.changed_files(**self.get_json_body())

if body["code"] != 0:
self.set_status(500)
self.finish(json.dumps(body))


Expand Down

0 comments on commit 1a9c004

Please sign in to comment.