Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jupyterlab_git/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ async def init(self, path):
}
return {"code": code, "actions": actions}

async def _empty_commit_for_init(self, path):
async def _empty_commit(self, path):
cmd = ["git", "commit", "--allow-empty", "-m", '"First Commit"']

code, _, error = await self.__execute(cmd, cwd=path)
Expand Down
11 changes: 10 additions & 1 deletion jupyterlab_git/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,15 @@ async def post(self, path: str = ""):

if data["checkout_branch"]:
if data["new_check"]:
# Need to check if startpoint is valid
is_start_point_valid = await self.git._get_branch_reference(
data["startpoint"], local_path
)

# If start point is not valid, we need to make an empty commit
if not is_start_point_valid:
await self.git._empty_commit(local_path)

body = await self.git.checkout_new_branch(
data["branchname"], data["startpoint"], local_path
)
Expand Down Expand Up @@ -716,7 +725,7 @@ async def post(self, path: str = ""):
body = await self.git.init(self.url2localpath(path))

if body["code"] == 0:
body = await self.git._empty_commit_for_init(self.url2localpath(path))
body = await self.git._empty_commit(self.url2localpath(path))

if body["code"] != 0:
self.set_status(500)
Expand Down
Loading