Skip to content
This repository was archived by the owner on Dec 29, 2025. It is now read-only.

Commit 0eb34ae

Browse files
Add shallow fetch to improve performance for large repositories (anthropics#53)
* Add shallow fetch to improve performance for large repositories This change adds `--depth=1` to git fetch operations to perform shallow fetches instead of full history downloads. This significantly reduces checkout time for large repositories as reported in issue anthropics#52. Changes: - Line 55: Added --depth=1 to PR branch fetch - Line 102: Added --depth=1 to new branch fetch Fixes anthropics#52 Co-authored-by: ashwin-ant <ashwin-ant@users.noreply.github.com> * fetch 50 commits for PRs --------- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: ashwin-ant <ashwin-ant@users.noreply.github.com>
1 parent 804959a commit 0eb34ae

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/github/operations/branch.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ export async function setupBranch(
5151

5252
const branchName = prData.headRefName;
5353

54-
// Execute git commands to checkout PR branch
55-
await $`git fetch origin ${branchName}`;
54+
// Execute git commands to checkout PR branch (shallow fetch for performance)
55+
// Fetch the branch with a depth of 20 to avoid fetching too much history, while still allowing for some context
56+
await $`git fetch origin --depth=20 ${branchName}`;
5657
await $`git checkout ${branchName}`;
5758

5859
console.log(`Successfully checked out PR branch for PR #${entityNumber}`);
@@ -98,8 +99,8 @@ export async function setupBranch(
9899
sha: currentSHA,
99100
});
100101

101-
// Checkout the new branch
102-
await $`git fetch origin ${newBranch}`;
102+
// Checkout the new branch (shallow fetch for performance)
103+
await $`git fetch origin --depth=1 ${newBranch}`;
103104
await $`git checkout ${newBranch}`;
104105

105106
console.log(

0 commit comments

Comments
 (0)