Bladeren bron

Closes #600 - adds (un)stage directory support

main
Tony Brix 6 jaren geleden
committed by Eric Amodio
bovenliggende
commit
6b60917da7
4 gewijzigde bestanden met toevoegingen van 72 en 0 verwijderingen
  1. +36
    -0
      package.json
  2. +20
    -0
      src/git/gitService.ts
  3. +1
    -0
      src/views/nodes.ts
  4. +15
    -0
      src/views/viewCommands.ts

+ 36
- 0
package.json Bestand weergeven

@ -2258,6 +2258,15 @@
"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",
"category": "GitLens",
@ -2267,6 +2276,15 @@
}
},
{
"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",
"category": "GitLens",
@ -3052,10 +3070,18 @@
"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"
},
@ -4432,6 +4458,16 @@
"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)/",
"group": "9_gitlens@1"

+ 20
- 0
src/git/gitService.ts Bestand weergeven

@ -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()
@ -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);

+ 1
- 0
src/views/nodes.ts Bestand weergeven

@ -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';

+ 15
- 0
src/views/viewCommands.ts Bestand weergeven

@ -23,6 +23,7 @@ import {
canDismissNode,
CommitFileNode,
CommitNode,
FolderNode,
RemoteNode,
RepositoryNode,
ResultsFileNode,
@ -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);
@ -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;

Laden…
Annuleren
Opslaan