summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorRyooooooga <eial5q265e5@gmail.com>2022-04-23 11:42:24 +0900
committerRyooooooga <eial5q265e5@gmail.com>2022-04-23 12:25:42 +0900
commitf972d6ae681bd17edd6f3c52d2ca40d1147118f0 (patch)
tree17430a0ec859f6b01535bba4176ec8c3c400ed7c /pkg/gui
parent11d0e7e17df94407695e28831b4005de3a86f326 (diff)
feat(gui): show remote icons
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/presentation/icons/git_icons.go38
-rw-r--r--pkg/gui/presentation/remotes.go8
2 files changed, 40 insertions, 6 deletions
diff --git a/pkg/gui/presentation/icons/git_icons.go b/pkg/gui/presentation/icons/git_icons.go
index 8acfead2b..0f891d7bd 100644
--- a/pkg/gui/presentation/icons/git_icons.go
+++ b/pkg/gui/presentation/icons/git_icons.go
@@ -1,14 +1,31 @@
package icons
import (
+ "strings"
+
"github.com/jesseduffield/lazygit/pkg/commands/models"
)
-const BRANCH_ICON = "\ufb2b" // שׂ
-const DETACHED_HEAD_ICON = "\ue729" // 
-const TAG_ICON = "\uf02b" // 
-const COMMIT_ICON = "\ufc16" // ﰖ
-const MERGE_COMMIT_ICON = "\ufb2c" // שּׁ
+const (
+ BRANCH_ICON = "\ufb2b" // שׂ
+ DETACHED_HEAD_ICON = "\ue729" // 
+ TAG_ICON = "\uf02b" // 
+ 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 {
if branch.DisplayName != "" {
@@ -31,3 +48,14 @@ func IconForCommit(commit *models.Commit) string {
}
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
+}
diff --git a/pkg/gui/presentation/remotes.go b/pkg/gui/presentation/remotes.go
index 9b26cbfae..7f82fe970 100644
--- a/pkg/gui/presentation/remotes.go
+++ b/pkg/gui/presentation/remotes.go
@@ -3,6 +3,7 @@ package presentation
import (
"github.com/jesseduffield/generics/slices"
"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/theme"
)
@@ -23,5 +24,10 @@ func getRemoteDisplayStrings(r *models.Remote, diffed bool) []string {
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
}