From 6ab5d7f69ba51f9b261cc2179ef8f82cfa35be81 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 15 Jun 2023 13:25:32 +0200 Subject: [PATCH] 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. --- pkg/gui/presentation/icons/git_icons.go | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/pkg/gui/presentation/icons/git_icons.go b/pkg/gui/presentation/icons/git_icons.go index a66149b55..342e015fe 100644 --- a/pkg/gui/presentation/icons/git_icons.go +++ b/pkg/gui/presentation/icons/git_icons.go @@ -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 } } }