Adds index (staged changes) to timeline

This commit is contained in:
Eric Amodio
2020-01-23 08:13:24 -05:00
committed by Eric Amodio
parent d7b5fe4cc7
commit 2dc90b8140
2 changed files with 25 additions and 1 deletions

View File

@@ -2334,6 +2334,10 @@ export class CommandCenter {
@command('git.openDiff', { repository: false })
async openDiff(uri: Uri, hash: string) {
if (hash === '~') {
return commands.executeCommand('vscode.diff', toGitUri(uri, hash), toGitUri(uri, `HEAD`));
}
return commands.executeCommand('vscode.diff', toGitUri(uri, hash), toGitUri(uri, `${hash}^`));
}

View File

@@ -60,7 +60,7 @@ export class GitTimelineProvider implements TimelineProvider {
console.log(`GitTimelineProvider.provideTimeline: commits=${commits.length}`);
return commits.map<TimelineItem>(c => {
const items = commits.map<TimelineItem>(c => {
let message = c.message;
const index = message.indexOf('\n');
@@ -82,6 +82,26 @@ export class GitTimelineProvider implements TimelineProvider {
}
};
});
const index = repo.indexGroup.resourceStates.find(r => r.resourceUri.fsPath === uri.fsPath);
if (index) {
items.push({
id: '~',
// TODO: Fix the date
date: Date.now(),
iconPath: new ThemeIcon('git-commit'),
label: 'Staged Changes',
description: '',
detail: '',
command: {
title: 'Open Diff',
command: 'git.openDiff',
arguments: [uri, '~']
}
});
}
return items;
}
@debounce(500)