Skip to content

Commit

Permalink
update clone URL check for gitlab to account for gitlab instances hos…
Browse files Browse the repository at this point in the history
…ted with subpath

Signed-off-by: Philipp Winkler <[email protected]>
  • Loading branch information
philslab-ninja committed Dec 17, 2024
1 parent 52f8e05 commit 7b9da44
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server/events/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,13 @@ func NewRepo(vcsHostType VCSHostType, repoFullName string, cloneURL string, vcsU
// Azure DevOps also does not require .git at the end of clone urls.
if vcsHostType != BitbucketServer && vcsHostType != AzureDevops {
expClonePath := fmt.Sprintf("/%s.git", repoFullName)
if expClonePath != cloneURLParsed.Path {
if vcsHostType == Gitlab {
// For GitLab, we need to check if the path ends with our expected path
// This handles cases where GitLab is hosted at a subpath (e.g., acme.com/gitlab)
if !strings.HasSuffix(cloneURLParsed.Path, expClonePath) {
return Repo{}, fmt.Errorf("expected clone url path to end with %q but had %q", expClonePath, cloneURLParsed.Path)
}
} else if expClonePath != cloneURLParsed.Path {
return Repo{}, fmt.Errorf("expected clone url to have path %q but had %q", expClonePath, cloneURLParsed.Path)
}
}
Expand Down

0 comments on commit 7b9da44

Please sign in to comment.