Changes from fix/list-branch-issue-on-fresh-repo

This commit is contained in:
Kacper
2025-12-23 20:46:10 +01:00
parent 629b7e7433
commit 4958ee1dda
15 changed files with 386 additions and 47 deletions

View File

@@ -111,6 +111,19 @@ export async function isGitRepo(repoPath: string): Promise<boolean> {
}
}
/**
* Check if a git repository has at least one commit (i.e., HEAD exists)
* Returns false for freshly initialized repos with no commits
*/
export async function hasCommits(repoPath: string): Promise<boolean> {
try {
await execAsync('git rev-parse --verify HEAD', { cwd: repoPath });
return true;
} catch {
return false;
}
}
/**
* Check if an error is ENOENT (file/path not found or spawn failed)
* These are expected in test environments with mock paths