2022-09-01 20:25:41 +02:00
|
|
|
package presentation
|
|
|
|
|
|
|
|
import (
|
|
|
|
"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"
|
|
|
|
)
|
|
|
|
|
2022-09-11 07:36:47 +02:00
|
|
|
func GetWorktreeDisplayString(isCurrent bool, isPathMissing bool, worktree *models.Worktree) []string {
|
2022-09-01 20:25:41 +02:00
|
|
|
textStyle := theme.DefaultTextColor
|
|
|
|
|
|
|
|
current := ""
|
|
|
|
currentColor := style.FgCyan
|
2022-09-11 07:36:47 +02:00
|
|
|
if isCurrent {
|
2022-09-01 20:25:41 +02:00
|
|
|
current = " *"
|
|
|
|
currentColor = style.FgGreen
|
|
|
|
}
|
|
|
|
|
2022-09-11 07:36:47 +02:00
|
|
|
icon := icons.IconForWorktree(worktree, false)
|
|
|
|
if isPathMissing {
|
2022-09-02 18:35:08 +02:00
|
|
|
textStyle = style.FgRed
|
2022-09-11 07:36:47 +02:00
|
|
|
icon = icons.IconForWorktree(worktree, true)
|
2022-09-02 18:35:08 +02:00
|
|
|
}
|
|
|
|
|
2022-09-01 20:25:41 +02:00
|
|
|
res := make([]string, 0, 3)
|
|
|
|
res = append(res, currentColor.Sprint(current))
|
|
|
|
if icons.IsIconEnabled() {
|
2022-09-02 18:35:08 +02:00
|
|
|
res = append(res, textStyle.Sprint(icon))
|
2022-09-01 20:25:41 +02:00
|
|
|
}
|
2022-09-11 07:36:47 +02:00
|
|
|
res = append(res, textStyle.Sprint(worktree.Name()))
|
2022-09-01 20:25:41 +02:00
|
|
|
return res
|
|
|
|
}
|