Skip to content

Commit

Permalink
add (un)stageDirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech committed Dec 22, 2018
1 parent fe4c638 commit d32091d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
20 changes: 20 additions & 0 deletions src/git/gitService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2114,6 +2114,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 @@ -2124,6 +2134,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
16 changes: 4 additions & 12 deletions src/views/viewCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,9 @@ export class ViewCommands implements Disposable {
}

private async stageDirectory(node: ViewNode) {
if (!node.uri.repoPath) return;

// TODO: get fileNodes from node
const fileNodes: (CommitFileNode | StatusFileNode)[] = [];

for (const fileNode of fileNodes) {
void (await this.stageFile(fileNode));
}
void (await Container.git.stageDirectory(node.uri.repoPath, node.uri));
}

private async unstageFile(node: CommitFileNode | StatusFileNode) {
Expand All @@ -466,13 +462,9 @@ export class ViewCommands implements Disposable {
}

private async unstageDirectory(node: ViewNode) {
if (!node.uri.repoPath) return;

// TODO: get fileNodes from node
const fileNodes: (CommitFileNode | StatusFileNode)[] = [];

for (const fileNode of fileNodes) {
void (await this.unstageFile(fileNode));
}
void (await Container.git.unStageDirectory(node.uri.repoPath, node.uri));
}

async terminalCheckoutBranch(node: BranchNode) {
Expand Down

0 comments on commit d32091d

Please sign in to comment.