提交 817174b9 编写于 作者: J Joao Moreno

🐛 getCommitTemplate throws in non-git repo

上级 b32988a1
...@@ -45,14 +45,13 @@ async function init(context: ExtensionContext, disposables: Disposable[]): Promi ...@@ -45,14 +45,13 @@ async function init(context: ExtensionContext, disposables: Disposable[]): Promi
} }
const model = new Model(git, workspaceRootPath); const model = new Model(git, workspaceRootPath);
const commitTemplate = await model.getCommitTemplate();
outputChannel.appendLine(localize('using git', "Using git {0} from {1}", info.version, info.path)); outputChannel.appendLine(localize('using git', "Using git {0} from {1}", info.version, info.path));
git.onOutput(str => outputChannel.append(str), null, disposables); git.onOutput(str => outputChannel.append(str), null, disposables);
const commandCenter = new CommandCenter(git, model, outputChannel, telemetryReporter); const commandCenter = new CommandCenter(git, model, outputChannel, telemetryReporter);
const statusBarCommands = new StatusBarCommands(model); const statusBarCommands = new StatusBarCommands(model);
const provider = new GitSCMProvider(model, commandCenter, statusBarCommands, commitTemplate); const provider = new GitSCMProvider(model, commandCenter, statusBarCommands);
const contentProvider = new GitContentProvider(model); const contentProvider = new GitContentProvider(model);
const autoFetcher = new AutoFetcher(model); const autoFetcher = new AutoFetcher(model);
const mergeDecorator = new MergeDecorator(model); const mergeDecorator = new MergeDecorator(model);
......
...@@ -60,13 +60,11 @@ export class GitSCMProvider { ...@@ -60,13 +60,11 @@ export class GitSCMProvider {
constructor( constructor(
private model: Model, private model: Model,
private commandCenter: CommandCenter, private commandCenter: CommandCenter,
private statusBarCommands: StatusBarCommands, private statusBarCommands: StatusBarCommands
private commitTemplate: string
) { ) {
this._sourceControl = scm.createSourceControl('git', 'Git'); this._sourceControl = scm.createSourceControl('git', 'Git');
this.disposables.push(this._sourceControl); this.disposables.push(this._sourceControl);
this._sourceControl.commitTemplate = commitTemplate;
this._sourceControl.acceptInputCommand = { command: 'git.commitWithInput', title: localize('commit', "Commit") }; this._sourceControl.acceptInputCommand = { command: 'git.commitWithInput', title: localize('commit', "Commit") };
this._sourceControl.quickDiffProvider = this; this._sourceControl.quickDiffProvider = this;
...@@ -85,6 +83,15 @@ export class GitSCMProvider { ...@@ -85,6 +83,15 @@ export class GitSCMProvider {
this.disposables.push(this.workingTreeGroup); this.disposables.push(this.workingTreeGroup);
model.onDidChange(this.onDidModelChange, this, this.disposables); model.onDidChange(this.onDidModelChange, this, this.disposables);
this.updateCommitTemplate();
}
private async updateCommitTemplate(): Promise<void> {
try {
this._sourceControl.commitTemplate = await this.model.getCommitTemplate();
} catch (e) {
// noop
}
} }
provideOriginalResource(uri: Uri): Uri | undefined { provideOriginalResource(uri: Uri): Uri | undefined {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册