Skip to content

Commit 2dc90b8

Browse files
Eric Amodioeamodio
authored andcommitted
Adds index (staged changes) to timeline
1 parent d7b5fe4 commit 2dc90b8

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

extensions/git/src/commands.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2334,6 +2334,10 @@ export class CommandCenter {
23342334

23352335
@command('git.openDiff', { repository: false })
23362336
async openDiff(uri: Uri, hash: string) {
2337+
if (hash === '~') {
2338+
return commands.executeCommand('vscode.diff', toGitUri(uri, hash), toGitUri(uri, `HEAD`));
2339+
}
2340+
23372341
return commands.executeCommand('vscode.diff', toGitUri(uri, hash), toGitUri(uri, `${hash}^`));
23382342
}
23392343

extensions/git/src/timelineProvider.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class GitTimelineProvider implements TimelineProvider {
6060

6161
console.log(`GitTimelineProvider.provideTimeline: commits=${commits.length}`);
6262

63-
return commits.map<TimelineItem>(c => {
63+
const items = commits.map<TimelineItem>(c => {
6464
let message = c.message;
6565

6666
const index = message.indexOf('\n');
@@ -82,6 +82,26 @@ export class GitTimelineProvider implements TimelineProvider {
8282
}
8383
};
8484
});
85+
86+
const index = repo.indexGroup.resourceStates.find(r => r.resourceUri.fsPath === uri.fsPath);
87+
if (index) {
88+
items.push({
89+
id: '~',
90+
// TODO: Fix the date
91+
date: Date.now(),
92+
iconPath: new ThemeIcon('git-commit'),
93+
label: 'Staged Changes',
94+
description: '',
95+
detail: '',
96+
command: {
97+
title: 'Open Diff',
98+
command: 'git.openDiff',
99+
arguments: [uri, '~']
100+
}
101+
});
102+
}
103+
104+
return items;
85105
}
86106

87107
@debounce(500)

0 commit comments

Comments
 (0)