mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-16 10:58:34 -05:00
Addresses #57 - adds warning if no diff.tool
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Iterables } from '../system';
|
import { Iterables } from '../system';
|
||||||
import { TextEditor, Uri, window } from 'vscode';
|
import { commands, TextEditor, Uri, window } from 'vscode';
|
||||||
import { ActiveEditorCommand, Commands } from './common';
|
import { ActiveEditorCommand, Commands } from './common';
|
||||||
|
import { BuiltInCommands } from '../constants';
|
||||||
import { GitService } from '../gitService';
|
import { GitService } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { CommandQuickPickItem, BranchesQuickPick } from '../quickPicks';
|
import { CommandQuickPickItem, BranchesQuickPick } from '../quickPicks';
|
||||||
@@ -13,6 +14,13 @@ export class DiffDirectoryCommand extends ActiveEditorCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async execute(editor: TextEditor, uri?: Uri, shaOrBranch1?: string, shaOrBranch2?: string): Promise<any> {
|
async execute(editor: TextEditor, uri?: Uri, shaOrBranch1?: string, shaOrBranch2?: string): Promise<any> {
|
||||||
|
const diffTool = await this.git.getConfig('diff.tool');
|
||||||
|
if (!diffTool) {
|
||||||
|
const result = await window.showWarningMessage(`Unable to open directory compare because there is no Git diff tool configured`, 'View Git Docs');
|
||||||
|
if (!result) return undefined;
|
||||||
|
return commands.executeCommand(BuiltInCommands.Open, Uri.parse('https://git-scm.com/docs/git-config#git-config-difftool'));
|
||||||
|
}
|
||||||
|
|
||||||
if (!(uri instanceof Uri)) {
|
if (!(uri instanceof Uri)) {
|
||||||
uri = editor && editor.document && editor.document.uri;
|
uri = editor && editor.document && editor.document.uri;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,6 +150,10 @@ export class Git {
|
|||||||
return gitCommand(repoPath, ...params);
|
return gitCommand(repoPath, ...params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static config_get(key: string, repoPath?: string) {
|
||||||
|
return gitCommand(repoPath || '', `config`, `--get`, key);
|
||||||
|
}
|
||||||
|
|
||||||
static diff_nameStatus(repoPath: string, sha1?: string, sha2?: string) {
|
static diff_nameStatus(repoPath: string, sha1?: string, sha2?: string) {
|
||||||
const params = [`diff`, `--name-status`, `-M`];
|
const params = [`diff`, `--name-status`, `-M`];
|
||||||
if (sha1) {
|
if (sha1) {
|
||||||
|
|||||||
@@ -510,6 +510,12 @@ export class GitService extends Disposable {
|
|||||||
return Git.normalizePath(fileName).toLowerCase();
|
return Git.normalizePath(fileName).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getConfig(key: string, repoPath?: string): Promise<string> {
|
||||||
|
Logger.log(`getConfig('${key}', '${repoPath}')`);
|
||||||
|
|
||||||
|
return await Git.config_get(key, repoPath);
|
||||||
|
}
|
||||||
|
|
||||||
getGitUriForFile(fileName: string) {
|
getGitUriForFile(fileName: string) {
|
||||||
const cacheKey = this.getCacheEntryKey(fileName);
|
const cacheKey = this.getCacheEntryKey(fileName);
|
||||||
const entry = this._uriCache.get(cacheKey);
|
const entry = this._uriCache.get(cacheKey);
|
||||||
|
|||||||
Reference in New Issue
Block a user