Skip to content

Commit 761632c

Browse files
committed
Allow port in webDomain for services config values
1 parent ebd56bd commit 761632c

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

pkg/commands/hosting_service/hosting_service.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,13 @@ func (self *HostingServiceMgr) getCandidateServiceDomains() []ServiceDomain {
101101

102102
if len(self.configServiceDomains) > 0 {
103103
for gitDomain, typeAndDomain := range self.configServiceDomains {
104-
splitData := strings.Split(typeAndDomain, ":")
105-
if len(splitData) != 2 {
104+
provider, webDomain, success := strings.Cut(typeAndDomain, ":")
105+
106+
if !success {
106107
self.log.Errorf("Unexpected format for git service: '%s'. Expected something like 'github.com:github.com'", typeAndDomain)
107108
continue
108109
}
109110

110-
provider := splitData[0]
111-
webDomain := splitData[1]
112-
113111
serviceDefinition, ok := serviceDefinitionByProvider[provider]
114112
if !ok {
115113
providerNames := lo.Map(serviceDefinitions, func(serviceDefinition ServiceDefinition, _ int) string {

pkg/commands/hosting_service/hosting_service_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,18 @@ func TestGetPullRequestURL(t *testing.T) {
340340
},
341341
expectedLoggedErrors: nil,
342342
},
343+
{
344+
testName: "Does not log error when config service webDomain contains a port",
345+
from: "feature/profile-page",
346+
remoteUrl: "[email protected]:johndoe/social_network.git",
347+
configServiceDomains: map[string]string{
348+
"my.domain.test": "gitlab:my.domain.test:1111",
349+
},
350+
test: func(url string, err error) {
351+
assert.NoError(t, err)
352+
assert.Equal(t, "https://my.domain.test:1111/johndoe/social_network/-/merge_requests/new?merge_request[source_branch]=feature%2Fprofile-page", url)
353+
},
354+
},
343355
{
344356
testName: "Logs error when config service domain is malformed",
345357
from: "feature/profile-page",

0 commit comments

Comments
 (0)