Skip to content

Commit c48326b

Browse files
committed
fix add_all_untracked
Bash pipes weren't working with the subprocess.Popen. This finds all untracked files from the status function and adds them
1 parent e1edbd4 commit c48326b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

jupyterlab_git/git.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -596,14 +596,18 @@ async def add_all_unstaged(self, top_repo_path):
596596

597597
async def add_all_untracked(self, top_repo_path):
598598
"""
599-
Execute git add all untracked command & return the result.
599+
Find all untracked files, execute git add & return the result.
600600
"""
601-
cmd = ["echo", "a\n*\nq\n", "|", "git", "add", "-i"]
602-
code, _, error = await execute(cmd, cwd=top_repo_path)
601+
status = await self.status(top_repo_path)
602+
if status["code"] != 0:
603+
return status
603604

604-
if code != 0:
605-
return {"code": code, "command": " ".join(cmd), "message": error}
606-
return {"code": code}
605+
unstaged = []
606+
for f in status["files"]:
607+
if f["x"]=="?" and f["y"]=="?":
608+
unstaged.append(f["from"].strip('"'))
609+
610+
return await self.add(unstaged, top_repo_path)
607611

608612
async def reset(self, filename, top_repo_path):
609613
"""

0 commit comments

Comments
 (0)