diff --git a/CHANGELOG.md b/CHANGELOG.md index 63ae897..75e838e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - Adds support for vscode's Git file revisions (e.g. `Open File (HEAD)`) and diffs (e.g. `Open Changes`) - Adds new entry in the `History View` of the `GitLens` view - Adds blame annotations, navigation & comparison commands, etc +- Adds support for files with staged changes + - Adds new entry in the `Repository View` of the `GitLens` view ## [6.3.0-beta] - 2017-11-27 ### Added diff --git a/src/views/statusFilesNode.ts b/src/views/statusFilesNode.ts index 1284ade..f6f43e9 100644 --- a/src/views/statusFilesNode.ts +++ b/src/views/statusFilesNode.ts @@ -43,13 +43,42 @@ export class StatusFilesNode extends ExplorerNode { } if (this.status.files.length !== 0 && this.includeWorkingTree) { - statuses.splice(0, 0, ...this.status.files.map(s => { - return { - ...s, - commit: new GitLogCommit(GitCommitType.File, repoPath, GitService.uncommittedSha, s.fileName, 'You', new Date(), '', s.status, [s], s.originalFileName, 'HEAD', s.fileName) - } as IGitStatusFileWithCommit; + statuses.splice(0, 0, ...Iterables.flatMap(this.status.files, s => { + if (s.workTreeStatus !== undefined && s.indexStatus !== undefined) { + // Decrements the date to guarantee this entry will be sorted after the previous entry (most recent first) + const older = new Date(); + older.setMilliseconds(older.getMilliseconds() - 1); + + return [ + { + ...s, + commit: new GitLogCommit(GitCommitType.File, repoPath, GitService.uncommittedSha, s.fileName, 'You', new Date(), '', s.status, [s], s.originalFileName, GitService.stagedUncommittedSha, s.fileName) + } as IGitStatusFileWithCommit, + { + ...s, + commit: new GitLogCommit(GitCommitType.File, repoPath, GitService.stagedUncommittedSha, s.fileName, 'You', older, '', s.status, [s], s.originalFileName, 'HEAD', s.fileName) + } as IGitStatusFileWithCommit + ]; + } + else if (s.indexStatus !== undefined) { + return [ + { + ...s, + commit: new GitLogCommit(GitCommitType.File, repoPath, GitService.stagedUncommittedSha, s.fileName, 'You', new Date(), '', s.status, [s], s.originalFileName, 'HEAD', s.fileName) + } as IGitStatusFileWithCommit + ]; + } + else { + return [ + { + ...s, + commit: new GitLogCommit(GitCommitType.File, repoPath, GitService.uncommittedSha, s.fileName, 'You', new Date(), '', s.status, [s], s.originalFileName, 'HEAD', s.fileName) + } as IGitStatusFileWithCommit + ]; + } })); } + statuses.sort((a, b) => b.commit.date.getTime() - a.commit.date.getTime()); const groups = Arrays.groupBy(statuses, s => s.fileName);