From 1622f99d5d396fc41998344beee1b7d01502d5a4 Mon Sep 17 00:00:00 2001 From: jolheiser Date: Thu, 8 Sep 2022 22:27:29 -0500 Subject: [PATCH] Change IDE to nvim and add way to open origin branch Signed-off-by: jolheiser --- cmd/branch.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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 }