mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-12 19:18:32 -05:00
Adds CodeLens for Diff'ing in blame
Other fixes and refactoring
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import {commands, Disposable, Position, Range, Uri, window} from 'vscode';
|
||||
import {Commands, VsCodeCommands} from './constants';
|
||||
import GitProvider from './gitProvider';
|
||||
import {basename} from 'path';
|
||||
|
||||
abstract class Command extends Disposable {
|
||||
private _subscriptions: Disposable;
|
||||
@@ -41,4 +42,33 @@ export class BlameCommand extends Command {
|
||||
return commands.executeCommand(VsCodeCommands.ShowReferences, uri, position, locations);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class DiffWithPreviousCommand extends Command {
|
||||
constructor(private git: GitProvider) {
|
||||
super(Commands.DiffWithPrevious);
|
||||
}
|
||||
|
||||
execute(uri?: Uri, sha?: string, compareWithSha?: string) {
|
||||
// TODO: Execute these in parallel rather than series
|
||||
return this.git.getVersionedFile(uri.path, sha).then(source => {
|
||||
this.git.getVersionedFile(uri.path, compareWithSha).then(compare => {
|
||||
const fileName = basename(uri.path);
|
||||
return commands.executeCommand(VsCodeCommands.Diff, Uri.file(source), Uri.file(compare), `${fileName} (${sha}) ↔ ${fileName} (${compareWithSha})`);
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class DiffWithWorkingCommand extends Command {
|
||||
constructor(private git: GitProvider) {
|
||||
super(Commands.DiffWithWorking);
|
||||
}
|
||||
|
||||
execute(uri?: Uri, sha?: string) {
|
||||
return this.git.getVersionedFile(uri.path, sha).then(compare => {
|
||||
const fileName = basename(uri.path);
|
||||
return commands.executeCommand(VsCodeCommands.Diff, uri, Uri.file(compare), `${fileName} (index) ↔ ${fileName} (${sha})`);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user