1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-12-22 00:17:37 +02:00

feat: add Codeberg as a supported git hosting service

Codeberg is a Gitea-based git hosting service that uses the same URL
patterns for pull requests and commits. This adds native support so
users don't need to manually configure it.
This commit is contained in:
Yadi Abdalhalim
2025-12-20 16:57:37 -06:00
committed by Stefan Haller
parent 3201695658
commit 24e9197be2
3 changed files with 55 additions and 2 deletions

View File

@@ -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

View File

@@ -75,6 +75,15 @@ 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,
@@ -82,6 +91,7 @@ var serviceDefinitions = []ServiceDefinition{
azdoServiceDef,
bitbucketServerServiceDef,
giteaServiceDef,
codebergServiceDef,
}
var defaultServiceDomains = []ServiceDomain{
@@ -110,4 +120,9 @@ var defaultServiceDomains = []ServiceDomain{
gitDomain: "try.gitea.io",
webDomain: "try.gitea.io",
},
{
serviceDefinition: codebergServiceDef,
gitDomain: "codeberg.org",
webDomain: "codeberg.org",
},
}

View File

@@ -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: "git@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 (SSH) with specific target",
from: "feature/new",
to: "dev",
remoteUrl: "git@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: "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",
@@ -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",