1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package presentation
import (
"time"
"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/gui/types"
"github.com/jesseduffield/lazygit/pkg/i18n"
"github.com/jesseduffield/lazygit/pkg/theme"
"github.com/jesseduffield/lazygit/pkg/utils"
"github.com/samber/lo"
)
func GetRemoteListDisplayStrings(
remotes []*models.Remote,
diffName string,
getItemOperation func(item types.HasUrn) types.ItemOperation,
tr *i18n.TranslationSet,
) [][]string {
return lo.Map(remotes, func(remote *models.Remote, _ int) []string {
diffed := remote.Name == diffName
return getRemoteDisplayStrings(remote, diffed, getItemOperation(remote), tr)
})
}
// getRemoteDisplayStrings returns the display string of branch
func getRemoteDisplayStrings(
r *models.Remote,
diffed bool,
itemOperation types.ItemOperation,
tr *i18n.TranslationSet,
) []string {
branchCount := len(r.Branches)
textStyle := theme.DefaultTextColor
if diffed {
textStyle = theme.DiffTerminalColor
}
res := make([]string, 0, 3)
if icons.IsIconEnabled() {
res = append(res, textStyle.Sprint(icons.IconForRemote(r)))
}
descriptionStr := style.FgBlue.Sprintf("%d branches", branchCount)
itemOperationStr := ItemOperationToString(itemOperation, tr)
if itemOperationStr != "" {
descriptionStr += " " + style.FgCyan.Sprint(itemOperationStr+" "+utils.Loader(time.Now()))
}
res = append(res, textStyle.Sprint(r.Name), descriptionStr)
return res
}
|