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 941e308719c..c173d9e9c3b 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 6a57806ac12..0b173f4bfd9 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -933,8 +933,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