mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-31 14:24:25 +03:00
Initial addition of support for worktrees
This commit is contained in:
committed by
Jesse Duffield
parent
52447e5d46
commit
f8ba899b87
35
pkg/gui/presentation/worktrees.go
Normal file
35
pkg/gui/presentation/worktrees.go
Normal file
@ -0,0 +1,35 @@
|
||||
package presentation
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/generics/slices"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/presentation/icons"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||
"github.com/jesseduffield/lazygit/pkg/theme"
|
||||
)
|
||||
|
||||
func GetWorktreeListDisplayStrings(worktrees []*models.Worktree) [][]string {
|
||||
return slices.Map(worktrees, func(worktree *models.Worktree) []string {
|
||||
return getWorktreeDisplayStrings(worktree)
|
||||
})
|
||||
}
|
||||
|
||||
// getWorktreeDisplayStrings returns the display string of branch
|
||||
func getWorktreeDisplayStrings(w *models.Worktree) []string {
|
||||
textStyle := theme.DefaultTextColor
|
||||
|
||||
current := ""
|
||||
currentColor := style.FgCyan
|
||||
if w.Current {
|
||||
current = " *"
|
||||
currentColor = style.FgGreen
|
||||
}
|
||||
|
||||
res := make([]string, 0, 3)
|
||||
res = append(res, currentColor.Sprint(current))
|
||||
if icons.IsIconEnabled() {
|
||||
res = append(res, textStyle.Sprint(icons.IconForWorktree(w)))
|
||||
}
|
||||
res = append(res, textStyle.Sprint(w.Name))
|
||||
return res
|
||||
}
|
Reference in New Issue
Block a user