UpdateBranch moves branch to ref. It uses `git branch --force` rather than `git update-ref` because update-ref will happily move a branch that is checked out in another worktree, leaving that worktree's index and working tree stale.
(branch, ref string)
| 27 | // `git update-ref` because update-ref will happily move a branch that is checked out in |
| 28 | // another worktree, leaving that worktree's index and working tree stale. |
| 29 | func (g *gitExecuter) UpdateBranch(branch, ref string) error { |
| 30 | cmd, err := g.client.Command(context.Background(), "branch", "--force", "--", branch, ref) |
| 31 | if err != nil { |
| 32 | return err |
| 33 | } |
| 34 | _, err = cmd.Output() |
| 35 | return err |
| 36 | } |
| 37 | |
| 38 | func (g *gitExecuter) Worktrees() ([]git.Worktree, error) { |
| 39 | return g.client.Worktrees(context.Background()) |