Adds gitlens.gitExplorer.includeWorkingTree setting

Adds auto-update for working trree
Fixes issues with working tree status
This commit is contained in:
Eric Amodio
2017-09-23 16:29:56 -04:00
parent 99d6da9c90
commit 393ec351f0
9 changed files with 123 additions and 33 deletions

View File

@@ -38,7 +38,7 @@ export class StatusFilesNode extends ExplorerNode {
statuses = [];
}
if (this.status.files.length !== 0 && this.git.config.insiders) {
if (this.status.files.length !== 0 && this.includeWorkingTree) {
statuses.splice(0, 0, ...this.status.files.map(s => {
return { ...s, commit: new GitLogCommit('file', this.status.repoPath, GitService.uncommittedSha, s.fileName, 'You', new Date(), '', s.status, [s], s.originalFileName, 'HEAD', s.fileName) } as IGitStatusFileWithCommit;
}));
@@ -61,12 +61,13 @@ export class StatusFilesNode extends ExplorerNode {
}
async getTreeItem(): Promise<TreeItem> {
// Start with any untracked files, since they won't be included in the next call
let files = (this.status.files === undefined) ? 0 : this.status.files.filter(s => s.status === '?').length;
let files = (this.status.files !== undefined && this.includeWorkingTree) ? this.status.files.length : 0;
const stats = await this.git.getChangedFilesCount(this.status.repoPath, this.git.config.insiders ? this.status.upstream : this.range);
if (stats !== undefined) {
files += stats.files;
if (this.status.upstream !== undefined) {
const stats = await this.git.getChangedFilesCount(this.status.repoPath, `${this.status.upstream}...`);
if (stats !== undefined) {
files += stats.files;
}
}
const label = `${files} file${files > 1 ? 's' : ''} changed`; // ${this.status.upstream === undefined ? '' : ` (ahead of ${this.status.upstream})`}`;
@@ -79,4 +80,9 @@ export class StatusFilesNode extends ExplorerNode {
return item;
}
private get includeWorkingTree(): boolean {
return this.git.config.gitExplorer.includeWorkingTree;
}
}