Skip to content

Commit

Permalink
Fix #612. Separate checkout and fetch history
Browse files Browse the repository at this point in the history
  • Loading branch information
rebornix committed Jan 7, 2019
1 parent 719cd78 commit 916ec48
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/github/pullRequestGitHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ export class PullRequestGitHelper {
// fetch the branch
let ref = `${pullRequest.head.ref}:${localBranchName}`;
Logger.debug(`Fetch ${remoteName}/${pullRequest.head.ref}:${localBranchName} - start`, PullRequestGitHelper.ID);
await repository.fetch(remoteName, ref);
await repository.fetch(remoteName, ref, 1);
Logger.debug(`Fetch ${remoteName}/${pullRequest.head.ref}:${localBranchName} - done`, PullRequestGitHelper.ID);
await repository.checkout(localBranchName);
// set remote tracking branch for the local branch
await repository.setBranchUpstream(localBranchName, `refs/remotes/${remoteName}/${pullRequest.head.ref}`);
await repository.pull(true);
PullRequestGitHelper.associateBranchWithPullRequest(repository, pullRequest, localBranchName);
}

Expand Down Expand Up @@ -73,11 +74,12 @@ export class PullRequestGitHelper {
Logger.appendLine(`Branch ${remoteName}/${branchName} doesn't exist on local disk yet.`, PullRequestGitHelper.ID);
const trackedBranchName = `refs/remotes/${remoteName}/${branchName}`;
Logger.appendLine(`Fetch tracked branch ${trackedBranchName}`, PullRequestGitHelper.ID);
await repository.fetch(remoteName, branchName);
await repository.fetch(remoteName, branchName, 1);
const trackedBranch = await repository.getBranch(trackedBranchName);
// create branch
await repository.createBranch(branchName, true, trackedBranch.commit);
await repository.setBranchUpstream(branchName, trackedBranchName);
await repository.pull(true);
}

await PullRequestGitHelper.associateBranchWithPullRequest(repository, pullRequest, branchName);
Expand Down
8 changes: 4 additions & 4 deletions src/typings/git.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const enum Status {
DELETED,
UNTRACKED,
IGNORED,
INTENT_TO_ADD,

ADDED_BY_US,
ADDED_BY_THEM,
Expand Down Expand Up @@ -128,8 +129,6 @@ export interface Repository {

clean(paths: string[]): Promise<void>;

clean(paths: string[]): Promise<void>;

apply(patch: string, reverse?: boolean): Promise<void>;
diff(cached?: boolean): Promise<string>;
diffWithHEAD(path: string): Promise<string>;
Expand All @@ -154,8 +153,8 @@ export interface Repository {
addRemote(name: string, url: string): Promise<void>;
removeRemote(name: string): Promise<void>;

fetch(remote?: string, ref?: string): Promise<void>;
pull(): Promise<void>;
fetch(remote?: string, ref?: string, depth?: number): Promise<void>;
pull(unshallow?: boolean): Promise<void>;
push(remoteName?: string, branchName?: string, setUpstream?: boolean): Promise<void>;
}

Expand Down Expand Up @@ -216,4 +215,5 @@ export const enum GitErrorCodes {
WrongCase = 'WrongCase',
CantLockRef = 'CantLockRef',
CantRebaseMultipleBranches = 'CantRebaseMultipleBranches',
PatchDoesNotApply = 'PatchDoesNotApply'
}

0 comments on commit 916ec48

Please sign in to comment.