mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-12-04 10:34:55 +02:00
Merge pull request #2557 from noahziheng/feature/add-gitea-pr
This commit is contained in:
commit
79dc1d9052
@ -474,7 +474,7 @@ services:
|
|||||||
Where:
|
Where:
|
||||||
|
|
||||||
- `gitDomain` stands for the domain used by git itself (i.e. the one present on clone URLs), e.g. `git.work.com`
|
- `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` or `gitlab`
|
- `provider` is one of `github`, `bitbucket`, `bitbucketServer`, `azuredevops`, `gitlab` or `gitea`
|
||||||
- `webDomain` is the URL where your git service exposes a web interface and APIs, e.g. `gitservice.work.com`
|
- `webDomain` is the URL where your git service exposes a web interface and APIs, e.g. `gitservice.work.com`
|
||||||
|
|
||||||
## Predefined commit message prefix
|
## Predefined commit message prefix
|
||||||
|
@ -64,12 +64,22 @@ var bitbucketServerServiceDef = ServiceDefinition{
|
|||||||
repoURLTemplate: "https://{{.webDomain}}/projects/{{.project}}/repos/{{.repo}}",
|
repoURLTemplate: "https://{{.webDomain}}/projects/{{.project}}/repos/{{.repo}}",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var giteaServiceDef = ServiceDefinition{
|
||||||
|
provider: "gitea",
|
||||||
|
pullRequestURLIntoDefaultBranch: "/compare/{{.From}}",
|
||||||
|
pullRequestURLIntoTargetBranch: "/compare/{{.To}}...{{.From}}",
|
||||||
|
commitURL: "/commit/{{.CommitSha}}",
|
||||||
|
regexStrings: defaultUrlRegexStrings,
|
||||||
|
repoURLTemplate: defaultRepoURLTemplate,
|
||||||
|
}
|
||||||
|
|
||||||
var serviceDefinitions = []ServiceDefinition{
|
var serviceDefinitions = []ServiceDefinition{
|
||||||
githubServiceDef,
|
githubServiceDef,
|
||||||
bitbucketServiceDef,
|
bitbucketServiceDef,
|
||||||
gitLabServiceDef,
|
gitLabServiceDef,
|
||||||
azdoServiceDef,
|
azdoServiceDef,
|
||||||
bitbucketServerServiceDef,
|
bitbucketServerServiceDef,
|
||||||
|
giteaServiceDef,
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultServiceDomains = []ServiceDomain{
|
var defaultServiceDomains = []ServiceDomain{
|
||||||
@ -93,4 +103,9 @@ var defaultServiceDomains = []ServiceDomain{
|
|||||||
gitDomain: "dev.azure.com",
|
gitDomain: "dev.azure.com",
|
||||||
webDomain: "dev.azure.com",
|
webDomain: "dev.azure.com",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
serviceDefinition: giteaServiceDef,
|
||||||
|
gitDomain: "try.gitea.io",
|
||||||
|
webDomain: "try.gitea.io",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
"github.com/jesseduffield/generics/slices"
|
"github.com/jesseduffield/generics/slices"
|
||||||
)
|
)
|
||||||
|
|
||||||
// This package is for handling logic specific to a git hosting service like github, gitlab, bitbucket, etc.
|
// This package is for handling logic specific to a git hosting service like github, gitlab, bitbucket, gitea, etc.
|
||||||
// Different git hosting services have different URL formats for when you want to open a PR or view a commit,
|
// Different git hosting services have different URL formats for when you want to open a PR or view a commit,
|
||||||
// and this package's responsibility is to determine which service you're using based on the remote URL,
|
// and this package's responsibility is to determine which service you're using based on the remote URL,
|
||||||
// and then which URL you need for whatever use case you have.
|
// and then which URL you need for whatever use case you have.
|
||||||
|
@ -264,6 +264,60 @@ func TestGetPullRequestURL(t *testing.T) {
|
|||||||
assert.Equal(t, "https://mycompany.bitbucket.com/projects/myproject/repos/myrepo/pull-requests?create&targetBranch=dev&sourceBranch=feature%2Fnew", url)
|
assert.Equal(t, "https://mycompany.bitbucket.com/projects/myproject/repos/myrepo/pull-requests?create&targetBranch=dev&sourceBranch=feature%2Fnew", url)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
testName: "Opens a link to new pull request on Gitea Server (SSH)",
|
||||||
|
from: "feature/new",
|
||||||
|
remoteUrl: "ssh://git@mycompany.gitea.io/myproject/myrepo.git",
|
||||||
|
configServiceDomains: map[string]string{
|
||||||
|
// valid configuration for a gitea server URL
|
||||||
|
"mycompany.gitea.io": "gitea:mycompany.gitea.io",
|
||||||
|
},
|
||||||
|
test: func(url string, err error) {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, "https://mycompany.gitea.io/myproject/myrepo/compare/feature%2Fnew", url)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testName: "Opens a link to new pull request on Gitea Server (SSH) with specific target",
|
||||||
|
from: "feature/new",
|
||||||
|
to: "dev",
|
||||||
|
remoteUrl: "ssh://git@mycompany.gitea.io/myproject/myrepo.git",
|
||||||
|
configServiceDomains: map[string]string{
|
||||||
|
// valid configuration for a gitea server URL
|
||||||
|
"mycompany.gitea.io": "gitea:mycompany.gitea.io",
|
||||||
|
},
|
||||||
|
test: func(url string, err error) {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, "https://mycompany.gitea.io/myproject/myrepo/compare/dev...feature%2Fnew", url)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testName: "Opens a link to new pull request on Gitea Server (HTTP)",
|
||||||
|
from: "feature/new",
|
||||||
|
remoteUrl: "https://mycompany.gitea.io/myproject/myrepo.git",
|
||||||
|
configServiceDomains: map[string]string{
|
||||||
|
// valid configuration for a gitea server URL
|
||||||
|
"mycompany.gitea.io": "gitea:mycompany.gitea.io",
|
||||||
|
},
|
||||||
|
test: func(url string, err error) {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, "https://mycompany.gitea.io/myproject/myrepo/compare/feature%2Fnew", url)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testName: "Opens a link to new pull request on Gitea Server (HTTP) with specific target",
|
||||||
|
from: "feature/new",
|
||||||
|
to: "dev",
|
||||||
|
remoteUrl: "https://mycompany.gitea.io/myproject/myrepo.git",
|
||||||
|
configServiceDomains: map[string]string{
|
||||||
|
// valid configuration for a gitea server URL
|
||||||
|
"mycompany.gitea.io": "gitea:mycompany.gitea.io",
|
||||||
|
},
|
||||||
|
test: func(url string, err error) {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, "https://mycompany.gitea.io/myproject/myrepo/compare/dev...feature%2Fnew", url)
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
testName: "Throws an error if git service is unsupported",
|
testName: "Throws an error if git service is unsupported",
|
||||||
from: "feature/divide-operation",
|
from: "feature/divide-operation",
|
||||||
@ -310,7 +364,7 @@ func TestGetPullRequestURL(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, "https://bitbucket.org/johndoe/social_network/pull-requests/new?source=feature%2Fprofile-page&t=1", url)
|
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"},
|
expectedLoggedErrors: []string{"Unknown git service type: 'noservice'. Expected one of github, bitbucket, gitlab, azuredevops, bitbucketServer, gitea"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
testName: "Escapes reserved URL characters in from branch name",
|
testName: "Escapes reserved URL characters in from branch name",
|
||||||
|
Loading…
Reference in New Issue
Block a user