in src/github/operations/branch.ts [242:272]
export async function ensureBranchHistory(branch: string, depth?: number) {
console.log(`Fetching history of ${branch}...`);
try {
if (depth === undefined) {
// For full history: unshallow if repository is shallow
// Replace by unshallow-slice
const isShallow = await $`test -f .git/shallow`.nothrow().then(r => r.exitCode === 0);
if (isShallow) {
console.log(`Repository is shallow, fetching full history...`);
await $`git fetch --unshallow origin +${branch}:refs/remotes/origin/${branch}`;
} else {
await $`git fetch origin +${branch}:refs/remotes/origin/${branch}`;
}
} else {
// For limited depth
await $`git fetch origin --depth=${depth} +${branch}:refs/remotes/origin/${branch}`;
}
console.log(`✓ Successfully fetched ${branch} history`);
} catch (error) {
throw new Error(
`❌ Failed to fetch ${branch} history. ` +
`This could be due to:\n` +
`• Branch "${branch}" does not exist in the repository\n` +
`• Network connectivity issues\n` +
`• Insufficient permissions to fetch from the repository\n` +
`• Git authentication problems\n` +
`Original error: ${error instanceof Error ? error.message : String(error)}`
);
}
}