Skip to content

Commit

Permalink
git: cache isFreshRepository
Browse files Browse the repository at this point in the history
related to microsoft#57854
  • Loading branch information
joaomoreno committed Sep 20, 2018
1 parent 56f9c20 commit 7c2d950
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion extensions/git/src/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ export class Repository implements Disposable {

private isRepositoryHuge = false;
private didWarnAboutLimit = false;
private isFreshRepository: boolean | undefined = undefined;
private disposables: Disposable[] = [];

constructor(
Expand Down Expand Up @@ -1306,7 +1307,12 @@ export class Repository implements Disposable {

// Disable `Discard All Changes` for "fresh" repositories
// https://github.com/Microsoft/vscode/issues/43066
commands.executeCommand('setContext', 'gitFreshRepository', !this._HEAD || !this._HEAD.commit);
const isFreshRepository = !this._HEAD || !this._HEAD.commit;

if (this.isFreshRepository !== isFreshRepository) {
commands.executeCommand('setContext', 'gitFreshRepository', isFreshRepository);
this.isFreshRepository = isFreshRepository;
}

this._onDidChangeStatus.fire();
}
Expand Down

0 comments on commit 7c2d950

Please sign in to comment.