소스 검색

Fixes #798 - multiple repo fetch/push/pull fails

main
Eric Amodio 5 년 전
부모
커밋
b4c96c5796
4개의 변경된 파일34개의 추가작업 그리고 10개의 파일을 삭제
  1. +1
    -0
      CHANGELOG.md
  2. +7
    -3
      src/git/gitService.ts
  3. +26
    -6
      src/system/decorators/gate.ts
  4. +0
    -1
      src/views/nodes/fileHistoryTrackerNode.ts

+ 1
- 0
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

+ 7
- 3
src/git/gitService.ts 파일 보기

@ -511,7 +511,9 @@ export class GitService implements Disposable {
return Git.fetch(repoPath, options);
}
@gate()
@gate<GitService['fetchAll']>(
(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<GitService['pullAll']>(
(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<GitService['pushAll']>(repos => `${repos === undefined ? '' : repos.map(r => r.id).join(',')}`)
@log({
args: {
0: (repos?: Repository[]) => (repos === undefined ? false : repos.map(r => r.name).join(', '))

+ 26
- 6
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<T extends (...arg: any) => any>(resolver?: (...args: Parameters<T>) => 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<T>))}`;
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;
});
}

+ 0
- 1
src/views/nodes/fileHistoryTrackerNode.ts 파일 보기

@ -164,7 +164,6 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode
this.canSubscribe = enabled;
}
@gate()
@log()
async showHistoryForUri(uri: GitUri, baseRef?: string) {
this._fileUri = uri;

불러오는 중...
취소
저장