Skip to content

Commit

Permalink
feat: switch to branch in createEmptyBranch
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Sep 26, 2024
1 parent 8412e8d commit b1ea872
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/core/src/resource/branchCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { nanoid } from 'nanoid'
import { getLocalDbFolder } from '../storage/path.js'
import { copyDir, ensureDir } from '../util/fs.js'
import type { MoquerieInstance } from '../instance.js'
import { resourceInstancesFolders } from './storage.js'
import { resourceInstancesFolders, switchToBranch } from './storage.js'
import { getCurrentBranchFolder } from './branch.js'

export interface CreateBranchOptions {
Expand Down Expand Up @@ -45,11 +45,15 @@ export async function createBranch(mq: MoquerieInstance, options: CreateBranchOp
}

/**
* Creates an empty branch with a random name.
* Creates an empty branch with a random name and switch to it
*/
export async function createEmptyBranch(mq: MoquerieInstance) {
return createBranch(mq, {
name: `test-${nanoid()}`,
const name = `test-${nanoid()}`

await createBranch(mq, {
name,
empty: true,
})

await switchToBranch(mq, name)
}

0 comments on commit b1ea872

Please sign in to comment.