Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs-master/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ services:
Where:

- `gitDomain` stands for the domain used by git itself (i.e. the one present on clone URLs), e.g. `git.work.com`
- `provider` is one of `github`, `bitbucket`, `bitbucketServer`, `azuredevops`, `gitlab` or `gitea`
- `provider` is one of `github`, `bitbucket`, `bitbucketServer`, `azuredevops`, `gitlab`, `gitea` or `codeberg`
- `webDomain` is the URL where your git service exposes a web interface and APIs, e.g. `gitservice.work.com`

## Predefined commit message prefix
Expand Down
15 changes: 15 additions & 0 deletions pkg/commands/hosting_service/definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,23 @@ var giteaServiceDef = ServiceDefinition{
repoURLTemplate: defaultRepoURLTemplate,
}

var codebergServiceDef = ServiceDefinition{
provider: "codeberg",
pullRequestURLIntoDefaultBranch: "/compare/{{.From}}",
pullRequestURLIntoTargetBranch: "/compare/{{.To}}...{{.From}}",
commitURL: "/commit/{{.CommitHash}}",
regexStrings: defaultUrlRegexStrings,
repoURLTemplate: defaultRepoURLTemplate,
}

var serviceDefinitions = []ServiceDefinition{
githubServiceDef,
bitbucketServiceDef,
gitLabServiceDef,
azdoServiceDef,
bitbucketServerServiceDef,
giteaServiceDef,
codebergServiceDef,
}

var defaultServiceDomains = []ServiceDomain{
Expand Down Expand Up @@ -110,4 +120,9 @@ var defaultServiceDomains = []ServiceDomain{
gitDomain: "try.gitea.io",
webDomain: "try.gitea.io",
},
{
serviceDefinition: codebergServiceDef,
gitDomain: "codeberg.org",
webDomain: "codeberg.org",
},
}
40 changes: 39 additions & 1 deletion pkg/commands/hosting_service/hosting_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,44 @@ func TestGetPullRequestURL(t *testing.T) {
assert.Equal(t, "https://mycompany.gitea.io/myproject/myrepo/compare/dev...feature%2Fnew", url)
},
},
{
testName: "Opens a link to new pull request on Codeberg (SSH)",
from: "feature/new",
remoteUrl: "[email protected]:johndoe/myrepo.git",
test: func(url string, err error) {
assert.NoError(t, err)
assert.Equal(t, "https://codeberg.org/johndoe/myrepo/compare/feature%2Fnew", url)
},
},
{
testName: "Opens a link to new pull request on Codeberg (SSH) with specific target",
from: "feature/new",
to: "dev",
remoteUrl: "[email protected]:johndoe/myrepo.git",
test: func(url string, err error) {
assert.NoError(t, err)
assert.Equal(t, "https://codeberg.org/johndoe/myrepo/compare/dev...feature%2Fnew", url)
},
},
{
testName: "Opens a link to new pull request on Codeberg (HTTP)",
from: "feature/new",
remoteUrl: "https://codeberg.org/johndoe/myrepo.git",
test: func(url string, err error) {
assert.NoError(t, err)
assert.Equal(t, "https://codeberg.org/johndoe/myrepo/compare/feature%2Fnew", url)
},
},
{
testName: "Opens a link to new pull request on Codeberg (HTTP) with specific target",
from: "feature/new",
to: "dev",
remoteUrl: "https://codeberg.org/johndoe/myrepo.git",
test: func(url string, err error) {
assert.NoError(t, err)
assert.Equal(t, "https://codeberg.org/johndoe/myrepo/compare/dev...feature%2Fnew", url)
},
},
{
testName: "Throws an error if git service is unsupported",
from: "feature/divide-operation",
Expand Down Expand Up @@ -505,7 +543,7 @@ func TestGetPullRequestURL(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, "https://bitbucket.org/johndoe/social_network/pull-requests/new?source=feature%2Fprofile-page&t=1", url)
},
expectedLoggedErrors: []string{"Unknown git service type: 'noservice'. Expected one of github, bitbucket, gitlab, azuredevops, bitbucketServer, gitea"},
expectedLoggedErrors: []string{"Unknown git service type: 'noservice'. Expected one of github, bitbucket, gitlab, azuredevops, bitbucketServer, gitea, codeberg"},
},
{
testName: "Escapes reserved URL characters in from branch name",
Expand Down