Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change clone URL check for gitlab to account for possible subpath #5177

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading