From 8dcb181fbc10f62584863911e2c155fae33d6a4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Cie=C5=9Blak?= Date: Mon, 14 Aug 2017 22:44:42 +0200 Subject: [PATCH] Load stashes only when needed --- extensions/git/src/commands.ts | 8 +++++--- extensions/git/src/model.ts | 13 +++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 762ea8e5384..26d516081e4 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -1104,13 +1104,14 @@ export class CommandCenter { @command('git.stashPop') async stashPop(): Promise { - const noStashes = this.model.stashes.length === 0; + let stashes = await this.model.getStashes(); + const noStashes = stashes.length === 0; if (noStashes){ window.showInformationMessage(localize('no stashes', "There are no stashes to restore.")); return; } - const picks = this.model.stashes.map(r => { return { label: `#${r.id}: ${r.description}`, description: "", derails: "", id: r.id }; }); + const picks = stashes.map(r => { return { label: `#${r.id}: ${r.description}`, description: "", derails: "", id: r.id }; }); const placeHolder = localize('pick stash', "Pick a stash"); const choice = await window.showQuickPick(picks, { placeHolder }); @@ -1122,7 +1123,8 @@ export class CommandCenter { @command('git.stashPopLatest') async stashPopLatest(): Promise { - const noStashes = this.model.stashes.length === 0; + let stashes = await this.model.getStashes(); + const noStashes = stashes.length === 0; if (noStashes){ window.showInformationMessage(localize('no stashes', "There are no stashes to restore.")); return; diff --git a/extensions/git/src/model.ts b/extensions/git/src/model.ts index 553938f29f8..0bcd68df8f0 100644 --- a/extensions/git/src/model.ts +++ b/extensions/git/src/model.ts @@ -346,11 +346,6 @@ export class Model implements Disposable { return this._remotes; } - private _stashes: Stash[] = []; - get stashes(): Stash[] { - return this._stashes; - } - private _operations = new OperationsImpl(); get operations(): Operations { return this._operations; } @@ -365,7 +360,6 @@ export class Model implements Disposable { this._HEAD = undefined; this._refs = []; this._remotes = []; - this._stashes = []; this._mergeGroup = new MergeGroup(); this._indexGroup = new IndexGroup(); this._workingTreeGroup = new WorkingTreeGroup(); @@ -580,6 +574,10 @@ export class Model implements Disposable { }); } + async getStashes(): Promise { + return await this.getStashes(); + } + private async run(operation: Operation, runOperation: () => Promise = () => Promise.resolve(null)): Promise { const run = async () => { this._operations = this._operations.start(operation); @@ -704,12 +702,11 @@ export class Model implements Disposable { // noop } - const [refs, remotes, stashes] = await Promise.all([this.repository.getRefs(), this.repository.getRemotes(), this.repository.getStashes()]); + const [refs, remotes] = await Promise.all([this.repository.getRefs(), this.repository.getRemotes()]); this._HEAD = HEAD; this._refs = refs; this._remotes = remotes; - this._stashes = stashes; const index: Resource[] = []; const workingTree: Resource[] = [];