Skip to content

Commit 0bfce1d

Browse files
authored
Merge pull request #561 from ianhi/fix_add_all_
Fix add_all_untracked and add_all_unstaged
2 parents 14e66f1 + bca35e4 commit 0bfce1d

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

jupyterlab_git/git.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -589,18 +589,22 @@ async def add_all_unstaged(self, top_repo_path):
589589

590590
if code != 0:
591591
return {"code": code, "command": " ".join(cmd), "message": error}
592-
return {"result": code}
592+
return {"code": code}
593593

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

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

605609
async def reset(self, filename, top_repo_path):
606610
"""

src/model.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ export class GitExtension implements IGitExtension {
266266
const data = await response.json();
267267
throw new ServerConnection.ResponseError(response, data.message);
268268
}
269+
270+
this.refreshStatus();
269271
return response.json();
270272
} catch (err) {
271273
throw new ServerConnection.NetworkError(err);
@@ -299,6 +301,7 @@ export class GitExtension implements IGitExtension {
299301
const data = await response.json();
300302
throw new ServerConnection.ResponseError(response, data.message);
301303
}
304+
302305
this.refreshStatus();
303306
return response.json();
304307
} catch (err) {

0 commit comments

Comments
 (0)