|
|
@ -47,6 +47,7 @@ export class DiffWithPreviousCommand extends EditorCommand { |
|
|
|
line = line || editor.selection.active.line; |
|
|
|
if (!sha) { |
|
|
|
return this.git.getBlameForLine(uri.fsPath, line) |
|
|
|
.catch(ex => console.error('[GitLens.DiffWithPreviousCommand]', 'getBlameForLine', ex)) |
|
|
|
.then(blame => { |
|
|
|
if (!blame) return; |
|
|
|
|
|
|
@ -64,6 +65,7 @@ export class DiffWithPreviousCommand extends EditorCommand { |
|
|
|
// TODO: Moving doesn't always seem to work -- or more accurately it seems like it moves down that number of lines from the current line
|
|
|
|
// which for a diff could be the first difference
|
|
|
|
return Promise.all([this.git.getVersionedFile(uri.fsPath, sha), this.git.getVersionedFile(uri.fsPath, compareWithSha)]) |
|
|
|
.catch(ex => console.error('[GitLens.DiffWithPreviousCommand]', 'getVersionedFile', ex)) |
|
|
|
.then(values => commands.executeCommand(BuiltInCommands.Diff, Uri.file(values[1]), Uri.file(values[0]), `${basename(compareWithUri.fsPath)} (${compareWithSha}) ↔ ${basename(shaUri.fsPath)} (${sha})`) |
|
|
|
.then(() => commands.executeCommand(BuiltInCommands.RevealLine, {lineNumber: line, at: 'center'}))); |
|
|
|
} |
|
|
@ -78,6 +80,7 @@ export class DiffWithWorkingCommand extends EditorCommand { |
|
|
|
line = line || editor.selection.active.line; |
|
|
|
if (!sha) { |
|
|
|
return this.git.getBlameForLine(uri.fsPath, line) |
|
|
|
.catch(ex => console.error('[GitLens.DiffWithWorkingCommand]', 'getBlameForLine', ex)) |
|
|
|
.then(blame => { |
|
|
|
if (!blame) return; |
|
|
|
|
|
|
@ -91,6 +94,7 @@ export class DiffWithWorkingCommand extends EditorCommand { |
|
|
|
// TODO: Moving doesn't always seem to work -- or more accurately it seems like it moves down that number of lines from the current line
|
|
|
|
// which for a diff could be the first difference
|
|
|
|
return this.git.getVersionedFile(shaUri.fsPath, sha) |
|
|
|
.catch(ex => console.error('[GitLens.DiffWithWorkingCommand]', 'getVersionedFile', ex)) |
|
|
|
.then(compare => commands.executeCommand(BuiltInCommands.Diff, Uri.file(compare), uri, `${basename(shaUri.fsPath)} (${sha}) ↔ ${basename(uri.fsPath)} (index)`) |
|
|
|
.then(() => commands.executeCommand(BuiltInCommands.RevealLine, {lineNumber: line, at: 'center'}))); |
|
|
|
} |
|
|
@ -108,6 +112,7 @@ export class ShowBlameCommand extends EditorCommand { |
|
|
|
|
|
|
|
const activeLine = editor.selection.active.line; |
|
|
|
return this.git.getBlameForLine(editor.document.fileName, activeLine) |
|
|
|
.catch(ex => console.error('[GitLens.ShowBlameCommand]', 'getBlameForLine', ex)) |
|
|
|
.then(blame => this.blameController.showBlame(editor, blame && blame.commit.sha)); |
|
|
|
} |
|
|
|
} |
|
|
@ -130,9 +135,11 @@ export class ShowBlameHistoryCommand extends EditorCommand { |
|
|
|
if (!uri) return; |
|
|
|
} |
|
|
|
|
|
|
|
return this.git.getBlameLocations(uri.fsPath, range).then(locations => { |
|
|
|
return commands.executeCommand(BuiltInCommands.ShowReferences, uri, position, locations); |
|
|
|
}); |
|
|
|
return this.git.getBlameLocations(uri.fsPath, range) |
|
|
|
.catch(ex => console.error('[GitLens.ShowBlameHistoryCommand]', 'getBlameLocations', ex)) |
|
|
|
.then(locations => { |
|
|
|
return commands.executeCommand(BuiltInCommands.ShowReferences, uri, position, locations); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -148,6 +155,7 @@ export class ToggleBlameCommand extends EditorCommand { |
|
|
|
|
|
|
|
const activeLine = editor.selection.active.line; |
|
|
|
return this.git.getBlameForLine(editor.document.fileName, activeLine) |
|
|
|
.catch(ex => console.error('[GitLens.ToggleBlameCommand]', 'getBlameForLine', ex)) |
|
|
|
.then(blame => this.blameController.toggleBlame(editor, blame && blame.commit.sha)); |
|
|
|
} |
|
|
|
} |