diff --git a/CHANGELOG.md b/CHANGELOG.md index c3df5d1..5ed9533 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ### Fixed +- Fixes [#798](https://github.com/eamodio/vscode-gitlens/issues/798) - git pull/fetch all repositories - Fixes [#805](https://github.com/eamodio/vscode-gitlens/issues/805) - Version 9.9.1 breaks working tree comparison ## [9.9.1] - 2019-07-23 diff --git a/src/git/gitService.ts b/src/git/gitService.ts index a538819..a959cf6 100644 --- a/src/git/gitService.ts +++ b/src/git/gitService.ts @@ -511,7 +511,9 @@ export class GitService implements Disposable { return Git.fetch(repoPath, options); } - @gate() + @gate( + (repos, opts) => `${repos === undefined ? '' : repos.map(r => r.id).join(',')}|${JSON.stringify(opts)}` + ) @log({ args: { 0: (repos?: Repository[]) => (repos === undefined ? false : repos.map(r => r.name).join(', ')) @@ -538,7 +540,9 @@ export class GitService implements Disposable { ); } - @gate() + @gate( + (repos, opts) => `${repos === undefined ? '' : repos.map(r => r.id).join(',')}|${JSON.stringify(opts)}` + ) @log({ args: { 0: (repos?: Repository[]) => (repos === undefined ? false : repos.map(r => r.name).join(', ')) @@ -565,7 +569,7 @@ export class GitService implements Disposable { ); } - @gate() + @gate(repos => `${repos === undefined ? '' : repos.map(r => r.id).join(',')}`) @log({ args: { 0: (repos?: Repository[]) => (repos === undefined ? false : repos.map(r => r.name).join(', ')) diff --git a/src/system/decorators/gate.ts b/src/system/decorators/gate.ts index a550aad..ced5e0e 100644 --- a/src/system/decorators/gate.ts +++ b/src/system/decorators/gate.ts @@ -1,7 +1,24 @@ 'use strict'; import { Promises } from '../promise'; -export function gate() { +const emptyStr = ''; + +function defaultResolver(...args: any[]): string { + if (args.length === 1) { + const arg0 = args[0]; + if (arg0 == null) return emptyStr; + if (typeof arg0 === 'string') return arg0; + if (typeof arg0 === 'number' || typeof arg0 === 'boolean') { + return String(arg0); + } + + return JSON.stringify(arg0); + } + + return JSON.stringify(args); +} + +export function gate any>(resolver?: (...args: Parameters) => string) { return (target: any, key: string, descriptor: PropertyDescriptor) => { let fn: Function | undefined; if (typeof descriptor.value === 'function') { @@ -15,8 +32,11 @@ export function gate() { const gateKey = `$gate$${key}`; descriptor.value = function(this: any, ...args: any[]) { - if (!Object.prototype.hasOwnProperty.call(this, gateKey)) { - Object.defineProperty(this, gateKey, { + const prop = + args.length === 0 ? gateKey : `${gateKey}$${(resolver || defaultResolver)(...(args as Parameters))}`; + + if (!Object.prototype.hasOwnProperty.call(this, prop)) { + Object.defineProperty(this, prop, { configurable: false, enumerable: false, writable: true, @@ -24,15 +44,15 @@ export function gate() { }); } - let promise = this[gateKey]; + let promise = this[prop]; if (promise === undefined) { const result = fn!.apply(this, args); if (result == null || !Promises.isPromise(result)) { return result; } - this[gateKey] = promise = result.then((r: any) => { - this[gateKey] = undefined; + this[prop] = promise = result.then((r: any) => { + this[prop] = undefined; return r; }); } diff --git a/src/views/nodes/fileHistoryTrackerNode.ts b/src/views/nodes/fileHistoryTrackerNode.ts index 921f8ee..863fc14 100644 --- a/src/views/nodes/fileHistoryTrackerNode.ts +++ b/src/views/nodes/fileHistoryTrackerNode.ts @@ -164,7 +164,6 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode