Skip to content

Commit b1e4415

Browse files
committed
Adds repo view entry for staged changes
1 parent b907b91 commit b1e4415

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
99
- Adds support for vscode's Git file revisions (e.g. `Open File (HEAD)`) and diffs (e.g. `Open Changes`)
1010
- Adds new entry in the `History View` of the `GitLens` view
1111
- Adds blame annotations, navigation & comparison commands, etc
12+
- Adds support for files with staged changes
13+
- Adds new entry in the `Repository View` of the `GitLens` view
1214

1315
## [6.3.0-beta] - 2017-11-27
1416
### Added

src/views/statusFilesNode.ts

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,42 @@ export class StatusFilesNode extends ExplorerNode {
4343
}
4444

4545
if (this.status.files.length !== 0 && this.includeWorkingTree) {
46-
statuses.splice(0, 0, ...this.status.files.map(s => {
47-
return {
48-
...s,
49-
commit: new GitLogCommit(GitCommitType.File, repoPath, GitService.uncommittedSha, s.fileName, 'You', new Date(), '', s.status, [s], s.originalFileName, 'HEAD', s.fileName)
50-
} as IGitStatusFileWithCommit;
46+
statuses.splice(0, 0, ...Iterables.flatMap(this.status.files, s => {
47+
if (s.workTreeStatus !== undefined && s.indexStatus !== undefined) {
48+
// Decrements the date to guarantee this entry will be sorted after the previous entry (most recent first)
49+
const older = new Date();
50+
older.setMilliseconds(older.getMilliseconds() - 1);
51+
52+
return [
53+
{
54+
...s,
55+
commit: new GitLogCommit(GitCommitType.File, repoPath, GitService.uncommittedSha, s.fileName, 'You', new Date(), '', s.status, [s], s.originalFileName, GitService.stagedUncommittedSha, s.fileName)
56+
} as IGitStatusFileWithCommit,
57+
{
58+
...s,
59+
commit: new GitLogCommit(GitCommitType.File, repoPath, GitService.stagedUncommittedSha, s.fileName, 'You', older, '', s.status, [s], s.originalFileName, 'HEAD', s.fileName)
60+
} as IGitStatusFileWithCommit
61+
];
62+
}
63+
else if (s.indexStatus !== undefined) {
64+
return [
65+
{
66+
...s,
67+
commit: new GitLogCommit(GitCommitType.File, repoPath, GitService.stagedUncommittedSha, s.fileName, 'You', new Date(), '', s.status, [s], s.originalFileName, 'HEAD', s.fileName)
68+
} as IGitStatusFileWithCommit
69+
];
70+
}
71+
else {
72+
return [
73+
{
74+
...s,
75+
commit: new GitLogCommit(GitCommitType.File, repoPath, GitService.uncommittedSha, s.fileName, 'You', new Date(), '', s.status, [s], s.originalFileName, 'HEAD', s.fileName)
76+
} as IGitStatusFileWithCommit
77+
];
78+
}
5179
}));
5280
}
81+
5382
statuses.sort((a, b) => b.commit.date.getTime() - a.commit.date.getTime());
5483

5584
const groups = Arrays.groupBy(statuses, s => s.fileName);

0 commit comments

Comments
 (0)