From d20bf0f881b3996ecd2c22489405dce3ece7921c Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Mon, 3 Jun 2024 10:15:33 +0200 Subject: [PATCH] feat(git): add icon for Codeberg upstream --- src/segments/git.go | 3 +++ src/segments/git_test.go | 2 ++ themes/schema.json | 6 ++++++ website/docs/segments/git.mdx | 1 + 4 files changed, 12 insertions(+) diff --git a/src/segments/git.go b/src/segments/git.go index d749f712..a7df4d44 100644 --- a/src/segments/git.go +++ b/src/segments/git.go @@ -101,6 +101,8 @@ const ( AzureDevOpsIcon properties.Property = "azure_devops_icon" // CodeCommit shows when upstream is aws codecommit CodeCommit properties.Property = "codecommit_icon" + // CodebergIcon shows when upstream is codeberg + CodebergIcon properties.Property = "codeberg_icon" // GitlabIcon shows when upstream is gitlab GitlabIcon properties.Property = "gitlab_icon" // GitIcon shows when the upstream can't be identified @@ -498,6 +500,7 @@ func (g *Git) getUpstreamIcon() string { "dev.azure.com": {AzureDevOpsIcon, "\uEBE8 "}, "visualstudio.com": {AzureDevOpsIcon, "\uEBE8 "}, "codecommit": {CodeCommit, "\uF270 "}, + "codeberg": {CodebergIcon, "\uF330 "}, } for key, value := range defaults { if strings.Contains(g.UpstreamURL, key) { diff --git a/src/segments/git_test.go b/src/segments/git_test.go index 1bafb553..9fdffaaa 100644 --- a/src/segments/git_test.go +++ b/src/segments/git_test.go @@ -672,6 +672,7 @@ func TestGitUpstream(t *testing.T) { {Case: "Azure DevOps", Expected: "AD", Upstream: "dev.azure.com/test"}, {Case: "Azure DevOps Dos", Expected: "AD", Upstream: "test.visualstudio.com"}, {Case: "CodeCommit", Expected: "AC", Upstream: "codecommit::eu-west-1://test-repository"}, + {Case: "Codeberg", Expected: "CB", Upstream: "codeberg.org:user/repo.git"}, {Case: "Gitstash", Expected: "G", Upstream: "gitstash.com/test"}, {Case: "My custom server", Expected: "CU", Upstream: "mycustom.server/test"}, } @@ -687,6 +688,7 @@ func TestGitUpstream(t *testing.T) { BitbucketIcon: "BB", AzureDevOpsIcon: "AD", CodeCommit: "AC", + CodebergIcon: "CB", GitIcon: "G", UpstreamIcons: map[string]string{ "mycustom.server": "CU", diff --git a/themes/schema.json b/themes/schema.json index 72342d89..26ff61f2 100644 --- a/themes/schema.json +++ b/themes/schema.json @@ -1328,6 +1328,12 @@ "description": "Icon/text to display when the upstream is CodeCommit", "default": "\uF270" }, + "codeberg_icon": { + "type": "string", + "title": "Codeberg Icon", + "description": "Icon/text to display when the upstream is Codeberg", + "default": "\uF330" + }, "git_icon": { "type": "string", "title": "Git Icon", diff --git a/website/docs/segments/git.mdx b/website/docs/segments/git.mdx index 6103c8d4..f2cf199c 100644 --- a/website/docs/segments/git.mdx +++ b/website/docs/segments/git.mdx @@ -116,6 +116,7 @@ You can set the following properties to `true` to enable fetching additional inf | `bitbucket_icon` | `string` | `\uF171` | icon/text to display when the upstream is Bitbucket | | `azure_devops_icon` | `string` | `\uEBE8` | icon/text to display when the upstream is Azure DevOps | | `codecommit_icon` | `string` | `\uF270` | icon/text to display when the upstream is AWS CodeCommit | +| `codeberg_icon` | `string` | `\uF330` | icon/text to display when the upstream is Codeberg | | `git_icon` | `string` | `\uE5FB` | icon/text to display when the upstream is not known/mapped | | `upstream_icons` | `map[string]string` | | a key, value map representing the remote URL (or a part of that URL) and icon to use in case the upstream URL contains the key. These get precedence over the standard icons |