mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-02 05:41:10 -08:00
refactor(git): use map for upstream icons
This commit is contained in:
parent
02c557f42e
commit
6f8733eacd
|
@ -337,17 +337,20 @@ func (g *Git) getUpstreamIcon() string {
|
|||
}
|
||||
g.RawUpstreamURL = g.getRemoteURL()
|
||||
g.UpstreamURL = cleanSSHURL(g.RawUpstreamURL)
|
||||
if strings.Contains(g.UpstreamURL, "github") {
|
||||
return g.props.GetString(GithubIcon, "\uF408 ")
|
||||
defaults := map[string]struct {
|
||||
Icon properties.Property
|
||||
Default string
|
||||
}{
|
||||
"github": {GithubIcon, "\uF408 "},
|
||||
"gitlab": {GitlabIcon, "\uF296 "},
|
||||
"bitbucket": {BitbucketIcon, "\uF171 "},
|
||||
"dev.azure.com": {AzureDevOpsIcon, "\uFD03 "},
|
||||
"visualstudio.com": {AzureDevOpsIcon, "\uFD03 "},
|
||||
}
|
||||
if strings.Contains(g.UpstreamURL, "gitlab") {
|
||||
return g.props.GetString(GitlabIcon, "\uF296 ")
|
||||
}
|
||||
if strings.Contains(g.UpstreamURL, "bitbucket") {
|
||||
return g.props.GetString(BitbucketIcon, "\uF171 ")
|
||||
}
|
||||
if strings.Contains(g.UpstreamURL, "dev.azure.com") || strings.Contains(g.UpstreamURL, "visualstudio.com") {
|
||||
return g.props.GetString(AzureDevOpsIcon, "\uFD03 ")
|
||||
for key, value := range defaults {
|
||||
if strings.Contains(g.UpstreamURL, key) {
|
||||
return g.props.GetString(value.Icon, value.Default)
|
||||
}
|
||||
}
|
||||
return g.props.GetString(GitIcon, "\uE5FB ")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue