summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-06-15 13:25:32 +0200
committerStefan Haller <stefan@haller-berlin.de>2023-06-15 13:25:32 +0200
commit6ab5d7f69ba51f9b261cc2179ef8f82cfa35be81 (patch)
tree2d4c8e4f75824fb9895d359add2d7b76e0740082 /pkg/gui
parentc410d2600634964f21881560c5ea88e9a42e5a2a (diff)
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.
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/presentation/icons/git_icons.go21
1 files 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
}
}
}