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:
committed by
Jesse Duffield
parent
afc4aedd4f
commit
60872c91e6
43
pkg/gui/controllers/helpers/worktree_helper.go
Normal file
43
pkg/gui/controllers/helpers/worktree_helper.go
Normal 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 ""
|
||||
}
|
Reference in New Issue
Block a user