From a76d768d2d9d6b3b678bc834c491694ea398cde3 Mon Sep 17 00:00:00 2001 From: Kilian PAQUIER Date: Fri, 3 May 2024 21:04:34 +0000 Subject: [PATCH] fix(checkout): try to checkout branch guessing it already exist before checkout with creation mode --- lib/git.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/git.ts b/lib/git.ts index 193f1dc..e81b474 100644 --- a/lib/git.ts +++ b/lib/git.ts @@ -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]) + } } /**