提交 7c8d8e82 编写于 作者: J Joao Moreno

git: enabled config

上级 e5a555bf
......@@ -373,6 +373,11 @@
"configuration": {
"title": "Git",
"properties": {
"git.enabled": {
"type": "boolean",
"description": "%config.enabled%",
"default": true
},
"git.path": {
"type": [
"string",
......@@ -432,4 +437,4 @@
"devDependencies": {
"@types/node": "^7.0.4"
}
}
}
\ No newline at end of file
......@@ -23,6 +23,7 @@
"command.sync": "Sync",
"command.publish": "Publish",
"command.showOutput": "Show Git Output",
"config.enabled": "Whether git is enabled",
"config.path": "Path to the git executable",
"config.autorefresh": "Whether auto refreshing is enabled",
"config.autofetch": "Whether auto fetching is enabled",
......
......@@ -128,14 +128,26 @@ export class CommandCenter {
};
}
private model: Model;
private disposables: Disposable[];
constructor(
private model: Model,
model: Model | undefined,
private outputChannel: OutputChannel
) {
if (model) {
this.model = model;
}
this.disposables = CommandCenter.Commands
.map(({ commandId, method }) => commands.registerCommand(commandId, method, this));
.map(({ commandId, method }) => commands.registerCommand(commandId, (...args) => {
if (!model) {
window.showInformationMessage(localize('disabled', "Git is either disabled or not supported in this workspace"));
return;
}
return method.apply(this, args);
}));
}
@CommandCenter.Command('git.refresh')
......
......@@ -21,9 +21,16 @@ import * as nls from 'vscode-nls';
const localize = nls.config()();
async function init(disposables: Disposable[]): Promise<void> {
const outputChannel = window.createOutputChannel('Git');
disposables.push(outputChannel);
const config = workspace.getConfiguration('git');
const enabled = config.get<boolean>('enabled') === true;
const rootPath = workspace.rootPath;
if (!rootPath) {
if (!rootPath || !enabled) {
const commandCenter = new CommandCenter(undefined, outputChannel);
disposables.push(commandCenter);
return;
}
......@@ -38,7 +45,6 @@ async function init(disposables: Disposable[]): Promise<void> {
const repositoryRoot = await repository.getRoot();
const model = new Model(repositoryRoot, repository, onWorkspaceChange);
const outputChannel = window.createOutputChannel('Git');
outputChannel.appendLine(localize('using git', "Using git {0} from {1}", info.version, info.path));
git.onOutput(str => outputChannel.append(str), null, disposables);
......@@ -56,7 +62,6 @@ async function init(disposables: Disposable[]): Promise<void> {
commandCenter,
provider,
contentProvider,
outputChannel,
fsWatcher,
checkoutStatusBar,
syncStatusBar,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册