Skip to content

Commit c589b2d

Browse files
committed
Set default branch to main for clone creation
When creating a clone without specifying a branch, both the UI and API now default to "main" branch instead of using the first available branch or the snapshot's branch. UI: Changed to prioritize "main" branch when selecting default. API: Changed default from snapshot.Branch to branching.DefaultBranch. Related: https://gitlab.com/postgres-ai/database-lab/-/issues/662
1 parent ce0b87c commit c589b2d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

engine/internal/cloning/base.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"gitlab.com/postgres-ai/database-lab/v3/pkg/log"
3131
"gitlab.com/postgres-ai/database-lab/v3/pkg/models"
3232
"gitlab.com/postgres-ai/database-lab/v3/pkg/util"
33+
"gitlab.com/postgres-ai/database-lab/v3/pkg/util/branching"
3334
"gitlab.com/postgres-ai/database-lab/v3/pkg/util/pglog"
3435
)
3536

@@ -172,7 +173,7 @@ func (c *Base) CreateClone(cloneRequest *types.CloneCreateRequest) (*models.Clon
172173
}
173174

174175
if cloneRequest.Branch == "" {
175-
cloneRequest.Branch = snapshot.Branch
176+
cloneRequest.Branch = branching.DefaultBranch
176177
}
177178

178179
clone := &models.Clone{

ui/packages/shared/pages/CreateClone/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ export const CreateClone = observer((props: Props) => {
103103

104104
const branches = (await stores.main.getBranches(props.instanceId)) ?? []
105105

106-
let initiallySelectedBranch = branches[0]?.name;
106+
const mainBranch = branches.find((branch) => branch.name === 'main')
107+
let initiallySelectedBranch = mainBranch?.name ?? branches[0]?.name;
107108

108109
if (initialBranch && branches.find((branch) => branch.name === initialBranch)) {
109110
initiallySelectedBranch = initialBranch;

0 commit comments

Comments
 (0)