Skip to content

Commit

Permalink
Add empty commit when initing repo (#1363)
Browse files Browse the repository at this point in the history
  • Loading branch information
gjmooney authored Oct 23, 2024
1 parent 2c0ec02 commit 544e89f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions jupyterlab_git/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,15 @@ async def init(self, path):
}
return {"code": code, "actions": actions}

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

code, _, error = await self.__execute(cmd, cwd=path)

if code != 0:
return {"code": code, "command": " ".join(cmd), "message": error}
return {"code": code}

async def _maybe_run_actions(self, name, cwd):
code = 0
actions = None
Expand Down
3 changes: 3 additions & 0 deletions jupyterlab_git/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,9 @@ 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))

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

Expand Down

0 comments on commit 544e89f

Please sign in to comment.