Skip to content

Commit 544e89f

Browse files
authored
Add empty commit when initing repo (#1363)
1 parent 2c0ec02 commit 544e89f

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

jupyterlab_git/git.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,6 +1323,15 @@ async def init(self, path):
13231323
}
13241324
return {"code": code, "actions": actions}
13251325

1326+
async def _empty_commit_for_init(self, path):
1327+
cmd = ["git", "commit", "--allow-empty", "-m", '"First Commit"']
1328+
1329+
code, _, error = await self.__execute(cmd, cwd=path)
1330+
1331+
if code != 0:
1332+
return {"code": code, "command": " ".join(cmd), "message": error}
1333+
return {"code": code}
1334+
13261335
async def _maybe_run_actions(self, name, cwd):
13271336
code = 0
13281337
actions = None

jupyterlab_git/handlers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,9 @@ async def post(self, path: str = ""):
715715
"""
716716
body = await self.git.init(self.url2localpath(path))
717717

718+
if body["code"] == 0:
719+
body = await self.git._empty_commit_for_init(self.url2localpath(path))
720+
718721
if body["code"] != 0:
719722
self.set_status(500)
720723

0 commit comments

Comments
 (0)