mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 04:15:48 +02:00
Allow adding a port to webDomain part of services config (#2908)
This commit is contained in:
commit
28353da61b
2 changed files with 28 additions and 5 deletions
|
@ -101,15 +101,14 @@ func (self *HostingServiceMgr) getCandidateServiceDomains() []ServiceDomain {
|
||||||
|
|
||||||
if len(self.configServiceDomains) > 0 {
|
if len(self.configServiceDomains) > 0 {
|
||||||
for gitDomain, typeAndDomain := range self.configServiceDomains {
|
for gitDomain, typeAndDomain := range self.configServiceDomains {
|
||||||
splitData := strings.Split(typeAndDomain, ":")
|
provider, webDomain, success := strings.Cut(typeAndDomain, ":")
|
||||||
if len(splitData) != 2 {
|
|
||||||
|
// we allow for one ':' for specifying the TCP port
|
||||||
|
if !success || strings.Count(webDomain, ":") > 1 {
|
||||||
self.log.Errorf("Unexpected format for git service: '%s'. Expected something like 'github.com:github.com'", typeAndDomain)
|
self.log.Errorf("Unexpected format for git service: '%s'. Expected something like 'github.com:github.com'", typeAndDomain)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
provider := splitData[0]
|
|
||||||
webDomain := splitData[1]
|
|
||||||
|
|
||||||
serviceDefinition, ok := serviceDefinitionByProvider[provider]
|
serviceDefinition, ok := serviceDefinitionByProvider[provider]
|
||||||
if !ok {
|
if !ok {
|
||||||
providerNames := lo.Map(serviceDefinitions, func(serviceDefinition ServiceDefinition, _ int) string {
|
providerNames := lo.Map(serviceDefinitions, func(serviceDefinition ServiceDefinition, _ int) string {
|
||||||
|
|
|
@ -340,6 +340,30 @@ func TestGetPullRequestURL(t *testing.T) {
|
||||||
},
|
},
|
||||||
expectedLoggedErrors: nil,
|
expectedLoggedErrors: nil,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
testName: "Does not log error when config service webDomain contains a port",
|
||||||
|
from: "feature/profile-page",
|
||||||
|
remoteUrl: "git@my.domain.test:johndoe/social_network.git",
|
||||||
|
configServiceDomains: map[string]string{
|
||||||
|
"my.domain.test": "gitlab:my.domain.test:1111",
|
||||||
|
},
|
||||||
|
test: func(url string, err error) {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, "https://my.domain.test:1111/johndoe/social_network/-/merge_requests/new?merge_request[source_branch]=feature%2Fprofile-page", url)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testName: "Logs error when webDomain contains more than one colon",
|
||||||
|
from: "feature/profile-page",
|
||||||
|
remoteUrl: "git@my.domain.test:johndoe/social_network.git",
|
||||||
|
configServiceDomains: map[string]string{
|
||||||
|
"my.domain.test": "gitlab:my.domain.test:1111:2222",
|
||||||
|
},
|
||||||
|
test: func(url string, err error) {
|
||||||
|
assert.Error(t, err)
|
||||||
|
},
|
||||||
|
expectedLoggedErrors: []string{"Unexpected format for git service: 'gitlab:my.domain.test:1111:2222'. Expected something like 'github.com:github.com'"},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
testName: "Logs error when config service domain is malformed",
|
testName: "Logs error when config service domain is malformed",
|
||||||
from: "feature/profile-page",
|
from: "feature/profile-page",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue