(
options: CreateBranchOptions
)
| 243 | } |
| 244 | |
| 245 | async createBranch( |
| 246 | options: CreateBranchOptions |
| 247 | ): Promise<Result<{ sequences: GitSequences }, CreateBranchError>> { |
| 248 | const name = options.name; |
| 249 | const from = options.from ?? 'HEAD'; |
| 250 | |
| 251 | if (options.syncWithRemote) { |
| 252 | const remote = options.remote ?? 'origin'; |
| 253 | const fetchResult = await this.fetch(remote); |
| 254 | if (!fetchResult.success) { |
| 255 | return err({ type: 'fetch_failed', remote, branch: from, error: fetchResult.error }); |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | const base = options.syncWithRemote ? `${options.remote ?? 'origin'}/${from}` : from; |
| 260 | try { |
| 261 | await this.exec.exec(['branch', '--no-track', '--', name, base]); |
| 262 | await this.setBranchBaseConfig(name, base); |
| 263 | return ok({ sequences: { refs: await this.refreshRefs() } }); |
| 264 | } catch (error) { |
| 265 | return err(classifyCreateBranchError(error, name, from)); |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | async deleteBranch( |
| 270 | branch: string, |
nothing calls this directly
no test coverage detected