2022-04-23 03:41:40 +02:00
|
|
|
package icons
|
|
|
|
|
2022-04-23 03:57:51 +02:00
|
|
|
import (
|
2022-04-23 04:42:24 +02:00
|
|
|
"strings"
|
|
|
|
|
2022-04-23 03:57:51 +02:00
|
|
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
|
|
|
)
|
2022-04-23 03:41:40 +02:00
|
|
|
|
2023-06-15 13:39:11 +02:00
|
|
|
var (
|
|
|
|
BRANCH_ICON = "\U000f062c" //
|
|
|
|
DETACHED_HEAD_ICON = "\ue729" //
|
|
|
|
TAG_ICON = "\uf02b" //
|
|
|
|
COMMIT_ICON = "\U000f0718" //
|
|
|
|
MERGE_COMMIT_ICON = "\U000f062d" //
|
|
|
|
DEFAULT_REMOTE_ICON = "\uf02a2" //
|
|
|
|
STASH_ICON = "\uf01c" //
|
2022-04-23 04:42:24 +02:00
|
|
|
)
|
|
|
|
|
2023-06-15 13:25:32 +02:00
|
|
|
var remoteIcons = map[string]string{
|
2023-06-15 13:39:11 +02:00
|
|
|
"github.com": "\ue709", //
|
|
|
|
"bitbucket.org": "\ue703", //
|
|
|
|
"gitlab.com": "\uf296", //
|
|
|
|
"dev.azure.com": "\U000f0805", //
|
|
|
|
}
|
|
|
|
|
|
|
|
func patchGitIconsForNerdFontsV2() {
|
|
|
|
BRANCH_ICON = "\ufb2b" // שׂ
|
|
|
|
COMMIT_ICON = "\ufc16" // ﰖ
|
|
|
|
MERGE_COMMIT_ICON = "\ufb2c" // שּׁ
|
|
|
|
DEFAULT_REMOTE_ICON = "\uf7a1" //
|
|
|
|
|
|
|
|
remoteIcons["dev.azure.com"] = "\ufd03" // ﴃ
|
2022-04-23 04:42:24 +02:00
|
|
|
}
|
2022-04-23 03:57:51 +02:00
|
|
|
|
|
|
|
func IconForBranch(branch *models.Branch) string {
|
2022-10-16 14:31:42 +02:00
|
|
|
if branch.DetachedHead {
|
2022-04-23 03:57:51 +02:00
|
|
|
return DETACHED_HEAD_ICON
|
|
|
|
}
|
|
|
|
return BRANCH_ICON
|
|
|
|
}
|
|
|
|
|
|
|
|
func IconForRemoteBranch(branch *models.RemoteBranch) string {
|
|
|
|
return BRANCH_ICON
|
|
|
|
}
|
|
|
|
|
|
|
|
func IconForTag(tag *models.Tag) string {
|
|
|
|
return TAG_ICON
|
|
|
|
}
|
2022-04-23 03:41:40 +02:00
|
|
|
|
|
|
|
func IconForCommit(commit *models.Commit) string {
|
|
|
|
if len(commit.Parents) > 1 {
|
|
|
|
return MERGE_COMMIT_ICON
|
|
|
|
}
|
|
|
|
return COMMIT_ICON
|
|
|
|
}
|
2022-04-23 04:42:24 +02:00
|
|
|
|
|
|
|
func IconForRemote(remote *models.Remote) string {
|
2023-06-15 13:25:32 +02:00
|
|
|
for domain, icon := range remoteIcons {
|
2022-04-23 04:42:24 +02:00
|
|
|
for _, url := range remote.Urls {
|
2023-06-15 13:25:32 +02:00
|
|
|
if strings.Contains(url, domain) {
|
|
|
|
return icon
|
2022-04-23 04:42:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return DEFAULT_REMOTE_ICON
|
|
|
|
}
|
2022-10-14 14:56:01 +02:00
|
|
|
|
|
|
|
func IconForStash(stash *models.StashEntry) string {
|
|
|
|
return STASH_ICON
|
|
|
|
}
|