Skip to content

Commit

Permalink
fix(checkout): try to checkout branch guessing it already exist befor…
Browse files Browse the repository at this point in the history
…e checkout with creation mode
  • Loading branch information
kilianpaquier committed May 4, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 7627264 commit a76d768
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/git.ts
Original file line number Diff line number Diff line change
@@ -28,9 +28,9 @@ export class Git {
* @throws an error if execa command fails.
*/
public async exec(args?: string[], options?: Options) {
return await execa("git", args, {
return await execa("git", args, {
...options,
cwd: this.cwd,
cwd: this.cwd,
env: this.env,
})
}
@@ -63,7 +63,11 @@ export class Git {
* @throws an error if the checkout cannot be done.
*/
public async checkout(branch: string) {
await this.exec(["checkout", "-b", branch])
try {
await this.exec(["checkout", branch])
} catch (error) {
await this.exec(["checkout", "-b", branch])
}
}

/**

0 comments on commit a76d768

Please sign in to comment.