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
36 changes: 36 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2257,6 +2257,15 @@
"title": "Unset as Default",
"category": "GitLens"
},
{
"command": "gitlens.views.stageDirectory",
"title": "Stage All Changes",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-add.svg",
"light": "images/light/icon-add.svg"
}
},
{
"command": "gitlens.views.stageFile",
"title": "Stage Changes",
Expand All @@ -2266,6 +2275,15 @@
"light": "images/light/icon-add.svg"
}
},
{
"command": "gitlens.views.unstageDirectory",
"title": "Unstage All Changes",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-minus.svg",
"light": "images/light/icon-minus.svg"
}
},
{
"command": "gitlens.views.unstageFile",
"title": "Unstage Changes",
Expand Down Expand Up @@ -3051,10 +3069,18 @@
"command": "gitlens.views.unsetAsDefault",
"when": "false"
},
{
"command": "gitlens.views.stageDirectory",
"when": "false"
},
{
"command": "gitlens.views.stageFile",
"when": "false"
},
{
"command": "gitlens.views.unstageDirectory",
"when": "false"
},
{
"command": "gitlens.views.unstageFile",
"when": "false"
Expand Down Expand Up @@ -4431,6 +4457,16 @@
"when": "view =~ /^gitlens\\.views\\./ && viewItem =~ /gitlens:(compare|folder|results|search|status:files)\\b/",
"group": "8_gitlens@1"
},
{
"command": "gitlens.views.stageDirectory",
"when": "view =~ /^gitlens\\.views\\./ && viewItem =~ /gitlens:folder\\b/",
"group": "7_gitlens@1"
},
{
"command": "gitlens.views.unstageDirectory",
"when": "view =~ /^gitlens\\.views\\./ && viewItem =~ /gitlens:folder\\b/",
"group": "7_gitlens@2"
},
{
"command": "gitlens.views.refreshNode",
"when": "view =~ /^gitlens\\.views\\./ && viewItem =~ /gitlens:(?!file\\b)/",
Expand Down
20 changes: 20 additions & 0 deletions src/git/gitService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2132,6 +2132,16 @@ export class GitService implements Disposable {
);
}

stageDirectory(repoPath: string, directory: string): Promise<string>;
stageDirectory(repoPath: string, uri: Uri): Promise<string>;
@log()
stageDirectory(repoPath: string, directoryOrUri: string | Uri): Promise<string> {
return Git.add(
repoPath,
typeof directoryOrUri === 'string' ? directoryOrUri : Git.splitPath(directoryOrUri.fsPath, repoPath)[0]
);
}

unStageFile(repoPath: string, fileName: string): Promise<string>;
unStageFile(repoPath: string, uri: Uri): Promise<string>;
@log()
Expand All @@ -2142,6 +2152,16 @@ export class GitService implements Disposable {
);
}

unStageDirectory(repoPath: string, directory: string): Promise<string>;
unStageDirectory(repoPath: string, uri: Uri): Promise<string>;
@log()
unStageDirectory(repoPath: string, directoryOrUri: string | Uri): Promise<string> {
return Git.reset(
repoPath,
typeof directoryOrUri === 'string' ? directoryOrUri : Git.splitPath(directoryOrUri.fsPath, repoPath)[0]
);
}

@log()
stashApply(repoPath: string, stashName: string, deleteAfter: boolean = false) {
return Git.stash_apply(repoPath, stashName, deleteAfter);
Expand Down
1 change: 1 addition & 0 deletions src/views/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export * from './nodes/commitFileNode';
export * from './nodes/commitNode';
export * from './nodes/fileHistoryNode';
export * from './nodes/fileHistoryTrackerNode';
export * from './nodes/folderNode';
export * from './nodes/lineHistoryNode';
export * from './nodes/lineHistoryTrackerNode';
export * from './nodes/remoteNode';
Expand Down
15 changes: 15 additions & 0 deletions src/views/viewCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
canDismissNode,
CommitFileNode,
CommitNode,
FolderNode,
RemoteNode,
RepositoryNode,
ResultsFileNode,
Expand Down Expand Up @@ -98,7 +99,9 @@ export class ViewCommands implements Disposable {
commands.registerCommand('gitlens.views.checkout', this.checkout, this);

commands.registerCommand('gitlens.views.stageFile', this.stageFile, this);
commands.registerCommand('gitlens.views.stageDirectory', this.stageDirectory, this);
commands.registerCommand('gitlens.views.unstageFile', this.unstageFile, this);
commands.registerCommand('gitlens.views.unstageDirectory', this.unstageDirectory, this);

commands.registerCommand('gitlens.views.compareAncestryWithWorking', this.compareAncestryWithWorking, this);
commands.registerCommand('gitlens.views.compareWithHead', this.compareWithHead, this);
Expand Down Expand Up @@ -464,12 +467,24 @@ export class ViewCommands implements Disposable {
return;
}

private async stageDirectory(node: FolderNode) {
if (!(node instanceof FolderNode) || !node.relativePath) return;

void (await Container.git.stageDirectory(node.repoPath, node.relativePath));
}

private async stageFile(node: CommitFileNode | StatusFileNode) {
if (!(node instanceof CommitFileNode) && !(node instanceof StatusFileNode)) return;

void (await Container.git.stageFile(node.repoPath, node.file.fileName));
}

private async unstageDirectory(node: FolderNode) {
if (!(node instanceof FolderNode) || !node.relativePath) return;

void (await Container.git.unStageDirectory(node.repoPath, node.relativePath));
}

private async unstageFile(node: CommitFileNode | StatusFileNode) {
if (!(node instanceof CommitFileNode) && !(node instanceof StatusFileNode)) return;

Expand Down