Skip to content

Commit 7125624

Browse files
authored
Merge pull request #341 from Staffbase/add-create-branch-if-not-exists
feat: add create branch if not exists
2 parents cc82fbd + bf90415 commit 7125624

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/autodev.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@ const autoDev = async (): Promise<void> => {
118118
)
119119
info(message)
120120
}
121+
122+
// check if the branch exists, if not create it from base
123+
const branchExists = await execAndSlurp(
124+
`git ls-remote --heads origin ${branch}`
125+
)
126+
if (!branchExists) {
127+
info(`Branch ${branch} does not exist. Creating branch from ${base}.`)
128+
await exec(`git checkout -b ${branch} ${base}`)
129+
await exec(`git push -u origin ${branch}`)
130+
}
121131
await exec(`git checkout -B ${branch}`)
122132

123133
// only push to defined branch if there are changes

0 commit comments

Comments
 (0)