From 94a04621ddc01231b45d7a7f09e99d03fe59312f Mon Sep 17 00:00:00 2001 From: Peng Lyu Date: Fri, 28 Dec 2018 12:02:28 -0800 Subject: [PATCH] Fix microsoft/vscode-pull-request-github#612. Allow fetching with limited depths --- extensions/git/src/api/api1.ts | 4 ++-- extensions/git/src/api/git.d.ts | 2 +- extensions/git/src/git.ts | 7 +++++-- extensions/git/src/repository.ts | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/extensions/git/src/api/api1.ts b/extensions/git/src/api/api1.ts index 9469580d97b..b1dce7dd99f 100644 --- a/extensions/git/src/api/api1.ts +++ b/extensions/git/src/api/api1.ts @@ -168,8 +168,8 @@ export class ApiRepository implements Repository { return this._repository.removeRemote(name); } - fetch(remote?: string | undefined, ref?: string | undefined): Promise { - return this._repository.fetch(remote, ref); + fetch(remote?: string | undefined, ref?: string | undefined, depth?: number | undefined): Promise { + return this._repository.fetch(remote, ref, depth); } pull(): Promise { diff --git a/extensions/git/src/api/git.d.ts b/extensions/git/src/api/git.d.ts index eb128be6609..258fe303917 100644 --- a/extensions/git/src/api/git.d.ts +++ b/extensions/git/src/api/git.d.ts @@ -153,7 +153,7 @@ export interface Repository { addRemote(name: string, url: string): Promise; removeRemote(name: string): Promise; - fetch(remote?: string, ref?: string): Promise; + fetch(remote?: string, ref?: string, depth?: number): Promise; pull(): Promise; push(remoteName?: string, branchName?: string, setUpstream?: boolean): Promise; } diff --git a/extensions/git/src/git.ts b/extensions/git/src/git.ts index 380ee42f411..d49a4258e87 100644 --- a/extensions/git/src/git.ts +++ b/extensions/git/src/git.ts @@ -1166,7 +1166,7 @@ export class Repository { await this.run(args); } - async fetch(options: { remote?: string, ref?: string, all?: boolean, prune?: boolean } = {}): Promise { + async fetch(options: { remote?: string, ref?: string, all?: boolean, prune?: boolean, depth?: number } = {}): Promise { const args = ['fetch']; if (options.remote) { @@ -1183,6 +1183,9 @@ export class Repository { args.push('--prune'); } + if (options.depth) { + args.push(`--depth=${options.depth}`); + } try { await this.run(args); @@ -1198,7 +1201,7 @@ export class Repository { } async pull(rebase?: boolean, remote?: string, branch?: string): Promise { - const args = ['pull', '--tags']; + const args = ['pull', '--tags', '--unshallow']; if (rebase) { args.push('-r'); diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index d97fcca9e13..aadce0545c1 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -908,8 +908,8 @@ export class Repository implements Disposable { await this.run(Operation.Fetch, () => this.repository.fetch({ all: true })); } - async fetch(remote?: string, ref?: string): Promise { - await this.run(Operation.Fetch, () => this.repository.fetch({ remote, ref })); + async fetch(remote?: string, ref?: string, depth?: number): Promise { + await this.run(Operation.Fetch, () => this.repository.fetch({ remote, ref, depth })); } @throttle