1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

Update status to differentiate the main vs linked worktrees

This commit is contained in:
Joel Baranick
2022-09-01 23:50:34 -07:00
committed by Jesse Duffield
parent afc4aedd4f
commit 60872c91e6
4 changed files with 71 additions and 4 deletions

View File

@ -0,0 +1,43 @@
package helpers
import (
"path/filepath"
)
type IWorktreeHelper interface {
GetMainWorktreeName() string
GetCurrentWorktreeName() string
}
type WorktreeHelper struct {
c *HelperCommon
}
func NewWorktreeHelper(c *HelperCommon) *WorktreeHelper {
return &WorktreeHelper{
c: c,
}
}
func (self *WorktreeHelper) GetMainWorktreeName() string {
for _, worktree := range self.c.Model().Worktrees {
if worktree.Main {
return filepath.Base(worktree.Path)
}
}
return ""
}
func (self *WorktreeHelper) GetCurrentWorktreeName() string {
for _, worktree := range self.c.Model().Worktrees {
if worktree.Current {
if worktree.Main {
return ""
}
return worktree.Name
}
}
return ""
}