mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-22 22:44:13 +08:00
feat: use dynamic fetch depth based on PR commit count
- Replace fixed depth of 20 with dynamic calculation - Use Math.max(commitCount, 20) to ensure minimum context
This commit is contained in:
@@ -45,9 +45,16 @@ export async function setupBranch(
|
|||||||
|
|
||||||
const branchName = prData.headRefName;
|
const branchName = prData.headRefName;
|
||||||
|
|
||||||
// Execute git commands to checkout PR branch (shallow fetch for performance)
|
// Determine optimal fetch depth based on PR commit count, with a minimum of 20
|
||||||
// Fetch the branch with a depth of 20 to avoid fetching too much history, while still allowing for some context
|
const commitCount = prData.commits.totalCount;
|
||||||
await $`git fetch origin --depth=20 ${branchName}`;
|
const fetchDepth = Math.max(commitCount, 20);
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`PR #${entityNumber}: ${commitCount} commits, using fetch depth ${fetchDepth}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Execute git commands to checkout PR branch (dynamic depth based on PR size)
|
||||||
|
await $`git fetch origin --depth=${fetchDepth} ${branchName}`;
|
||||||
await $`git checkout ${branchName}`;
|
await $`git checkout ${branchName}`;
|
||||||
|
|
||||||
console.log(`Successfully checked out PR branch for PR #${entityNumber}`);
|
console.log(`Successfully checked out PR branch for PR #${entityNumber}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user