fix: handle unborn HEAD branch creation

- Create orphan branches when HEAD does not exist yet\n- Use current branch as the default branch base in the toolbar\n- Keep push disabled for remote-less repos\n\nQuality gates: vitest repositories-settings-tab (passed); api pytest blocked by missing fastapi in environment
This commit is contained in:
2026-05-22 20:02:51 +02:00
parent 4547105f3b
commit 10cbe63095
3 changed files with 25 additions and 4 deletions
+6 -4
View File
@@ -112,7 +112,7 @@ export const GitToolbar = ({
if (!newBranchName.trim()) return;
setLoading(true);
try {
await createBranch(projectId, repoId, newBranchName, newBranchBase || "HEAD");
await createBranch(projectId, repoId, newBranchName, newBranchBase || currentBranch || "HEAD");
setShowNewBranch(false);
setNewBranchName("");
setNewBranchBase("");
@@ -131,6 +131,8 @@ export const GitToolbar = ({
status.untracked.length > 0
);
const canSync = hasRemote;
return (
<div className="git-toolbar">
{error && <div className="toolbar-error">{error}</div>}
@@ -169,7 +171,7 @@ export const GitToolbar = ({
<button
className="toolbar-button"
onClick={handleFetch}
disabled={loading || !hasRemote}
disabled={loading || !canSync}
type="button"
>
<Icon name="fetch" size="sm" /> Fetch
@@ -177,7 +179,7 @@ export const GitToolbar = ({
<button
className="toolbar-button"
onClick={handlePull}
disabled={loading || !hasRemote}
disabled={loading || !canSync}
type="button"
>
<Icon name="pull" size="sm" /> Pull
@@ -186,7 +188,7 @@ export const GitToolbar = ({
<button
className="toolbar-button"
onClick={handlePush}
disabled={loading || !status?.ahead}
disabled={loading || !canSync || !status?.ahead}
type="button"
>
<Icon name="push" size="sm" /> Push