Skip to content

Commit ff157f9

Browse files
committed
add unshallow as an option for git pull
1 parent bba335a commit ff157f9

4 files changed

Lines changed: 19 additions & 11 deletions

File tree

extensions/git/src/api/api1.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ export class ApiRepository implements Repository {
172172
return this._repository.fetch(remote, ref, depth);
173173
}
174174

175-
pull(): Promise<void> {
176-
return this._repository.pull();
175+
pull(unshallow?: boolean): Promise<void> {
176+
return this._repository.pull(undefined, unshallow);
177177
}
178178

179179
push(remoteName?: string, branchName?: string, setUpstream: boolean = false): Promise<void> {

extensions/git/src/api/git.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export interface Repository {
154154
removeRemote(name: string): Promise<void>;
155155

156156
fetch(remote?: string, ref?: string, depth?: number): Promise<void>;
157-
pull(): Promise<void>;
157+
pull(unshallow?: boolean): Promise<void>;
158158
push(remoteName?: string, branchName?: string, setUpstream?: boolean): Promise<void>;
159159
}
160160

extensions/git/src/git.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,10 @@ export interface CommitOptions {
629629
empty?: boolean;
630630
}
631631

632+
export interface PullOptions {
633+
unshallow?: boolean;
634+
}
635+
632636
export enum ForcePushMode {
633637
Force,
634638
ForceWithLease
@@ -1183,7 +1187,7 @@ export class Repository {
11831187
args.push('--prune');
11841188
}
11851189

1186-
if (options.depth) {
1190+
if (typeof options.depth === 'number') {
11871191
args.push(`--depth=${options.depth}`);
11881192
}
11891193

@@ -1200,8 +1204,12 @@ export class Repository {
12001204
}
12011205
}
12021206

1203-
async pull(rebase?: boolean, remote?: string, branch?: string): Promise<void> {
1204-
const args = ['pull', '--tags', '--unshallow'];
1207+
async pull(rebase?: boolean, remote?: string, branch?: string, options: PullOptions = {}): Promise<void> {
1208+
const args = ['pull', '--tags'];
1209+
1210+
if (options.unshallow) {
1211+
args.push('--unshallow');
1212+
}
12051213

12061214
if (rebase) {
12071215
args.push('-r');

extensions/git/src/repository.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ export class Repository implements Disposable {
951951
}
952952

953953
@throttle
954-
async pull(head?: Branch): Promise<void> {
954+
async pull(head?: Branch, unshallow?: boolean): Promise<void> {
955955
let remote: string | undefined;
956956
let branch: string | undefined;
957957

@@ -960,19 +960,19 @@ export class Repository implements Disposable {
960960
branch = `${head.upstream.name}`;
961961
}
962962

963-
return this.pullFrom(false, remote, branch);
963+
return this.pullFrom(false, remote, branch, unshallow);
964964
}
965965

966-
async pullFrom(rebase?: boolean, remote?: string, branch?: string): Promise<void> {
966+
async pullFrom(rebase?: boolean, remote?: string, branch?: string, unshallow?: boolean): Promise<void> {
967967
await this.run(Operation.Pull, async () => {
968968
await this.maybeAutoStash(async () => {
969969
const config = workspace.getConfiguration('git', Uri.file(this.root));
970970
const fetchOnPull = config.get<boolean>('fetchOnPull');
971971

972972
if (fetchOnPull) {
973-
await this.repository.pull(rebase);
973+
await this.repository.pull(rebase, undefined, undefined, { unshallow });
974974
} else {
975-
await this.repository.pull(rebase, remote, branch);
975+
await this.repository.pull(rebase, remote, branch, { unshallow });
976976
}
977977
});
978978
});

0 commit comments

Comments
 (0)