mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-31 14:24:25 +03:00
feat(gui): show remote icons
This commit is contained in:
@ -1,14 +1,31 @@
|
|||||||
package icons
|
package icons
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
const BRANCH_ICON = "\ufb2b" // שׂ
|
const (
|
||||||
const DETACHED_HEAD_ICON = "\ue729" //
|
BRANCH_ICON = "\ufb2b" // שׂ
|
||||||
const TAG_ICON = "\uf02b" //
|
DETACHED_HEAD_ICON = "\ue729" //
|
||||||
const COMMIT_ICON = "\ufc16" // ﰖ
|
TAG_ICON = "\uf02b" //
|
||||||
const MERGE_COMMIT_ICON = "\ufb2c" // שּׁ
|
COMMIT_ICON = "\ufc16" // ﰖ
|
||||||
|
MERGE_COMMIT_ICON = "\ufb2c" // שּׁ
|
||||||
|
DEFAULT_REMOTE_ICON = "\uf7a1" //
|
||||||
|
)
|
||||||
|
|
||||||
|
type remoteIcon struct {
|
||||||
|
domain string
|
||||||
|
icon string
|
||||||
|
}
|
||||||
|
|
||||||
|
var remoteIcons = []remoteIcon{
|
||||||
|
{domain: "github.com", icon: "\ue709"}, //
|
||||||
|
{domain: "bitbucket.org", icon: "\ue703"}, //
|
||||||
|
{domain: "gitlab.com", icon: "\uf296"}, //
|
||||||
|
{domain: "dev.azure.com", icon: "\ufd03"}, // ﴃ
|
||||||
|
}
|
||||||
|
|
||||||
func IconForBranch(branch *models.Branch) string {
|
func IconForBranch(branch *models.Branch) string {
|
||||||
if branch.DisplayName != "" {
|
if branch.DisplayName != "" {
|
||||||
@ -31,3 +48,14 @@ func IconForCommit(commit *models.Commit) string {
|
|||||||
}
|
}
|
||||||
return COMMIT_ICON
|
return COMMIT_ICON
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IconForRemote(remote *models.Remote) string {
|
||||||
|
for _, r := range remoteIcons {
|
||||||
|
for _, url := range remote.Urls {
|
||||||
|
if strings.Contains(url, r.domain) {
|
||||||
|
return r.icon
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return DEFAULT_REMOTE_ICON
|
||||||
|
}
|
||||||
|
@ -3,6 +3,7 @@ package presentation
|
|||||||
import (
|
import (
|
||||||
"github.com/jesseduffield/generics/slices"
|
"github.com/jesseduffield/generics/slices"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
"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/style"
|
||||||
"github.com/jesseduffield/lazygit/pkg/theme"
|
"github.com/jesseduffield/lazygit/pkg/theme"
|
||||||
)
|
)
|
||||||
@ -23,5 +24,10 @@ func getRemoteDisplayStrings(r *models.Remote, diffed bool) []string {
|
|||||||
textStyle = theme.DiffTerminalColor
|
textStyle = theme.DiffTerminalColor
|
||||||
}
|
}
|
||||||
|
|
||||||
return []string{textStyle.Sprint(r.Name), style.FgBlue.Sprintf("%d branches", branchCount)}
|
res := make([]string, 0, 3)
|
||||||
|
if icons.IsIconEnabled() {
|
||||||
|
res = append(res, textStyle.Sprint(icons.IconForRemote(r)))
|
||||||
|
}
|
||||||
|
res = append(res, textStyle.Sprint(r.Name), style.FgBlue.Sprintf("%d branches", branchCount))
|
||||||
|
return res
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user