🐛 getCommitTemplate throws in non-git repo

This commit is contained in:
Joao Moreno
2017-03-30 21:46:28 +02:00
parent b32988a1fd
commit 817174b971
2 changed files with 11 additions and 5 deletions

View File

@@ -60,13 +60,11 @@ export class GitSCMProvider {
constructor(
private model: Model,
private commandCenter: CommandCenter,
private statusBarCommands: StatusBarCommands,
private commitTemplate: string
private statusBarCommands: StatusBarCommands
) {
this._sourceControl = scm.createSourceControl('git', 'Git');
this.disposables.push(this._sourceControl);
this._sourceControl.commitTemplate = commitTemplate;
this._sourceControl.acceptInputCommand = { command: 'git.commitWithInput', title: localize('commit', "Commit") };
this._sourceControl.quickDiffProvider = this;
@@ -85,6 +83,15 @@ export class GitSCMProvider {
this.disposables.push(this.workingTreeGroup);
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 {