summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-07-16 13:43:20 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-07-30 18:35:22 +1000
commitc713d550c0a215408969838009865b6b906c7576 (patch)
tree51135aacf7384a69fdc4a3e4a160e75d9df0e8e2 /pkg/gui
parentd19d89ea9d99015ff4ea45027f0c56047256e7ea (diff)
Improve name handling
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/controllers/helpers/worktree_helper.go17
-rw-r--r--pkg/gui/presentation/worktrees.go8
2 files changed, 18 insertions, 7 deletions
diff --git a/pkg/gui/controllers/helpers/worktree_helper.go b/pkg/gui/controllers/helpers/worktree_helper.go
index 481442b2f..bdaf7d2f9 100644
--- a/pkg/gui/controllers/helpers/worktree_helper.go
+++ b/pkg/gui/controllers/helpers/worktree_helper.go
@@ -58,12 +58,17 @@ func (self *WorktreeHelper) IsWorktreePathMissing(w *models.Worktree) bool {
func (self *WorktreeHelper) NewWorktree() error {
return self.c.Prompt(types.PromptOpts{
Title: self.c.Tr.NewWorktreePath,
- HandleConfirm: func(response string) error {
- self.c.LogAction(self.c.Tr.Actions.CreateWorktree)
- if err := self.c.Git().Worktree.New(sanitizedBranchName(response)); err != nil {
- return err
- }
- return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
+ HandleConfirm: func(path string) error {
+ return self.c.Prompt(types.PromptOpts{
+ Title: self.c.Tr.NewWorktreePath,
+ HandleConfirm: func(committish string) error {
+ self.c.LogAction(self.c.Tr.Actions.CreateWorktree)
+ if err := self.c.Git().Worktree.New(sanitizedBranchName(path), committish); err != nil {
+ return err
+ }
+ return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
+ },
+ })
},
})
}
diff --git a/pkg/gui/presentation/worktrees.go b/pkg/gui/presentation/worktrees.go
index 55c1da08b..1161afc44 100644
--- a/pkg/gui/presentation/worktrees.go
+++ b/pkg/gui/presentation/worktrees.go
@@ -38,6 +38,12 @@ func GetWorktreeDisplayString(isCurrent bool, isPathMissing bool, worktree *mode
if icons.IsIconEnabled() {
res = append(res, textStyle.Sprint(icon))
}
- res = append(res, textStyle.Sprint(worktree.Name()))
+
+ name := worktree.Name()
+ if worktree.Main() {
+ // TODO: i18n
+ name += " (main worktree)"
+ }
+ res = append(res, textStyle.Sprint(name))
return res
}