Skip to content

Commit 85eb580

Browse files
add createBranch
1 parent 0d63915 commit 85eb580

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/SandboxClient/git.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,35 @@ export class Git {
4141
]);
4242
}
4343

44+
/**
45+
* Checkout a new branch and set upstream
46+
*/
47+
async createBranch(branch: string) {
48+
await this.commands.run([
49+
"git checkout -b " + branch,
50+
"git push --set-upstream origin " + branch,
51+
]);
52+
}
53+
4454
/**
4555
* Checkout a branch
4656
*/
47-
async checkout(branch: string, isNewBranch = false) {
57+
async checkout(
58+
ref: string,
59+
/**
60+
* @deprecated Use createBranch instead
61+
*/
62+
isNewBranch = false
63+
) {
4864
if (isNewBranch) {
4965
await this.commands.run([
50-
"git checkout -b " + branch,
51-
"git push --set-upstream origin " + branch,
66+
"git checkout -b " + ref,
67+
"git push --set-upstream origin " + ref,
5268
]);
5369
return;
5470
}
5571

56-
await this.commands.run(["git checkout " + branch]);
72+
await this.commands.run(["git checkout " + ref]);
5773
}
5874

5975
/**

0 commit comments

Comments
 (0)