diff --git a/cmd/branch.go b/cmd/branch.go index 532a232..56a6bea 100644 --- a/cmd/branch.go +++ b/cmd/branch.go @@ -6,7 +6,6 @@ import ( "flag" "fmt" "os" - "path/filepath" "strings" "github.com/peterbourgon/ff/v3/ffcli" @@ -52,7 +51,13 @@ func (h *Handler) Branch() *ffcli.Command { name := args[0] base := *baseFlag - if !strings.HasPrefix(base, "upstream") && !strings.HasPrefix(base, "pr-") { + switch { + case strings.HasPrefix(base, "o/"): + base = "origin/" + strings.TrimPrefix(base, "o/") + case strings.HasPrefix(base, "u/"): + base = "upstream/" + strings.TrimPrefix(base, "u/") + } + if (!strings.HasPrefix(base, "upstream") || !strings.HasPrefix(base, "origin")) && !strings.HasPrefix(base, "pr-") { base = fmt.Sprintf("upstream/%s", base) } @@ -60,7 +65,7 @@ func (h *Handler) Branch() *ffcli.Command { h.fetch(ctx) } - if err := h.run(ctx, "git", "worktree", "add", "-B", name, filepath.Join(h.Config.Workspace(), name), base); err != nil { + if err := h.run(ctx, "git", "worktree", "add", "-B", name, h.Config.WorkspaceBranch(name), base); err != nil { return err }