1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-02 23:27:32 +02:00

Turn remoteIcons into a map

We don't actually use it to do map lookups; we still iterate over it in the same
way as before. However, using a map makes it easier to patch elements; see the
next commit.
This commit is contained in:
Stefan Haller 2023-06-15 13:25:32 +02:00
parent c410d26006
commit 6ab5d7f69b

View File

@ -16,16 +16,11 @@ const (
STASH_ICON = "\uf01c" // 
)
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"}, // ﴃ
var remoteIcons = map[string]string{
"github.com": "\ue709", // 
"bitbucket.org": "\ue703", // 
"gitlab.com": "\uf296", // 
"dev.azure.com": "\ufd03", // ﴃ
}
func IconForBranch(branch *models.Branch) string {
@ -51,10 +46,10 @@ func IconForCommit(commit *models.Commit) string {
}
func IconForRemote(remote *models.Remote) string {
for _, r := range remoteIcons {
for domain, icon := range remoteIcons {
for _, url := range remote.Urls {
if strings.Contains(url, r.domain) {
return r.icon
if strings.Contains(url, domain) {
return icon
}
}
}