mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-03-12 09:27:22 +00:00
Improve git route behavior for repositories initialized with `git init` but with no commits yet. Previously, several routes called `git rev-parse --abbrev-ref HEAD`, which fails before the first commit and caused noisy console errors plus a broken Git panel state. What changed - add `getGitErrorDetails` helper to normalize git process failure text - add `isMissingHeadRevisionError` helper to detect no-HEAD/no-revision cases - add `getCurrentBranchName` helper: - uses `git symbolic-ref --short HEAD` first (works before first commit) - falls back to `git rev-parse --abbrev-ref HEAD` for detached HEAD and edge cases - add `repositoryHasCommits` helper using `git rev-parse --verify HEAD` Status route improvements - replace inline branch/HEAD error handling with shared helpers - keep returning valid branch + `hasCommits: false` for fresh repositories Remote status improvements - avoid hard failure when repository has no commits - return a safe, non-error payload with: - `hasUpstream: false` - `ahead: 0`, `behind: 0` - detected remote name when remotes exist - message: "Repository has no commits yet" - preserve existing upstream detection behavior for repositories with commits Consistency updates - switch fetch/pull/push/publish branch lookup to shared `getCurrentBranchName` to ensure the same branch-resolution behavior everywhere Result - `git init` repositories no longer trigger `rev-parse HEAD` ambiguity failures - Git panel remains usable before the first commit - backend branch detection is centralized and consistent across git operations