From ff20e6b6307ecab90bf591e504a072cce8942af7 Mon Sep 17 00:00:00 2001 From: Selmison Campelo de Miranda Date: Fri, 12 Mar 2021 19:18:13 -0300 Subject: [PATCH] Support basepath for gilab server --- server/events/models/models.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/events/models/models.go b/server/events/models/models.go index 39052ef3de..a961c63576 100644 --- a/server/events/models/models.go +++ b/server/events/models/models.go @@ -92,11 +92,15 @@ func NewRepo(vcsHostType VCSHostType, repoFullName string, cloneURL string, vcsU // and because the caller in that case actually constructs the clone url // from the repo name and so there's no point checking if they match. // Azure DevOps also does not require .git at the end of clone urls. - if vcsHostType != BitbucketServer && vcsHostType != AzureDevops { - expClonePath := fmt.Sprintf("/%s.git", repoFullName) + expClonePath := fmt.Sprintf("/%s.git", repoFullName) + if vcsHostType != BitbucketServer && vcsHostType != AzureDevops && vcsHostType != Gitlab { if expClonePath != cloneURLParsed.Path { return Repo{}, fmt.Errorf("expected clone url to have path %q but had %q", expClonePath, cloneURLParsed.Path) } + } else if vcsHostType == Gitlab { + if !strings.Contains(cloneURL, expClonePath) { + return Repo{}, fmt.Errorf("expected clone url to have path %q but had %q", expClonePath, cloneURLParsed.Path) + } } // We url encode because we're using them in a URL and weird characters can