Skip to content

Commit

Permalink
feat: azure devops support for git upstream icons
Browse files Browse the repository at this point in the history
  • Loading branch information
Micah Rairdon authored and JanDeDobbeleer committed May 15, 2021
1 parent 8b84f60 commit 36feb76
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/docs/segment-git.md
Expand Up @@ -66,6 +66,7 @@ Local changes can also shown by default using the following syntax for both the
- github_icon: `string` - icon/text to display when the upstream is Github - defaults to `\uF408 `
- gitlab_icon: `string` - icon/text to display when the upstream is Gitlab - defaults to `\uF296 `
- bitbucket_icon: `string` - icon/text to display when the upstream is Bitbucket - defaults to `\uF171 `
- azure_devops_icon: `string` - icon/text to display when the upstream is Azure DevOps - defaults to `\uFD03 `
- git_icon: `string` - icon/text to display when the upstream is not known/mapped - defaults to `\uE5FB `

### Colors
Expand Down
5 changes: 5 additions & 0 deletions src/segment_git.go
Expand Up @@ -92,6 +92,8 @@ const (
GithubIcon Property = "github_icon"
// BitbucketIcon shows when upstream is bitbucket
BitbucketIcon Property = "bitbucket_icon"
// AzureDevOpsIcon shows when upstream is azure devops
AzureDevOpsIcon Property = "azure_devops_icon"
// GitlabIcon shows when upstream is gitlab
GitlabIcon Property = "gitlab_icon"
// GitIcon shows when the upstream can't be identified
Expand Down Expand Up @@ -229,6 +231,9 @@ func (g *git) getUpstreamSymbol() string {
if strings.Contains(url, "bitbucket") {
return g.props.getString(BitbucketIcon, "\uF171 ")
}
if strings.Contains(url, "dev.azure.com") || strings.Contains(url, "visualstudio.com") {
return g.props.getString(AzureDevOpsIcon, "\uFD03 ")
}
return g.props.getString(GitIcon, "\uE5FB ")
}

Expand Down
19 changes: 15 additions & 4 deletions src/segment_git_test.go
Expand Up @@ -407,10 +407,11 @@ func bootstrapUpstreamTest(upstream string) *git {
env.On("getRuntimeGOOS", nil).Return("unix")
props := &properties{
values: map[Property]interface{}{
GithubIcon: "GH",
GitlabIcon: "GL",
BitbucketIcon: "BB",
GitIcon: "G",
GithubIcon: "GH",
GitlabIcon: "GL",
BitbucketIcon: "BB",
AzureDevOpsIcon: "AD",
GitIcon: "G",
},
}
g := &git{
Expand Down Expand Up @@ -441,6 +442,16 @@ func TestGetUpstreamSymbolBitBucket(t *testing.T) {
assert.Equal(t, "BB", upstreamIcon)
}

func TestGetUpstreamSymbolAzureDevOps(t *testing.T) {
g := bootstrapUpstreamTest("dev.azure.com/test")
upstreamIcon := g.getUpstreamSymbol()
assert.Equal(t, "AD", upstreamIcon)

g = bootstrapUpstreamTest("test.visualstudio.com")
upstreamIcon = g.getUpstreamSymbol()
assert.Equal(t, "AD", upstreamIcon)
}

func TestGetUpstreamSymbolGit(t *testing.T) {
g := bootstrapUpstreamTest("gitstash.com/test")
upstreamIcon := g.getUpstreamSymbol()
Expand Down
6 changes: 6 additions & 0 deletions themes/schema.json
Expand Up @@ -633,6 +633,12 @@
"description": "Icon/text to display when the upstream is Bitbucket",
"default": "\uF171"
},
"azure_devops_icon": {
"type": "string",
"title": "Azure DevOps Icon",
"description": "Icon/text to display when the upstream is Azure DevOps",
"default": "\uFD03"
},
"git_icon": {
"type": "string",
"title": "Git Icon",
Expand Down

0 comments on commit 36feb76

Please sign in to comment.