diff --git a/pkg/formatting/vcs.go b/pkg/formatting/vcs.go index d3beadfc0..713f8c1c4 100644 --- a/pkg/formatting/vcs.go +++ b/pkg/formatting/vcs.go @@ -3,7 +3,6 @@ package formatting import ( "fmt" "net/url" - "path/filepath" "strings" "golang.org/x/text/cases" @@ -51,7 +50,7 @@ func GetRepoOwnerSplitted(u string) (string, string, error) { if len(parts) < 3 { return "", "", fmt.Errorf("invalid repo url at least a organization/project and a repo needs to be specified: %s", u) } - org := filepath.Join(parts[0 : len(parts)-1]...) + org := parts[len(parts)-2] repo := parts[len(parts)-1] return org, repo, nil } diff --git a/pkg/provider/gitlab/gitlab_test.go b/pkg/provider/gitlab/gitlab_test.go index 383bd30b8..0335d5a1c 100644 --- a/pkg/provider/gitlab/gitlab_test.go +++ b/pkg/provider/gitlab/gitlab_test.go @@ -254,6 +254,8 @@ func TestSetClientDetectAPIURL(t *testing.T) { assert.ErrorContains(t, err, "no git_provider.secret has been set") event.Provider.Token = "hello" + event.TargetProjectID = 10 + event.SourceProjectID = 10 v.repoURL, event.URL, event.Provider.URL = "", "", "" event.URL = fmt.Sprintf("%s/hello-this-is-me-ze/project", fakehost) diff --git a/pkg/reconciler/event.go b/pkg/reconciler/event.go index cf69c816e..7df63bc49 100644 --- a/pkg/reconciler/event.go +++ b/pkg/reconciler/event.go @@ -62,9 +62,9 @@ func buildEventFromPipelineRun(pr *tektonv1.PipelineRun) *info.Event { event.URL = prAnno[keys.RepoURL] // it's safer to get repo, org from repo.url since we have to remove the / and other chars in labels which drops // the SubPath that gitlab is using. - repo, org, _ := formatting.GetRepoOwnerSplitted(event.URL) - event.Organization = repo - event.Repository = org + org, repo, _ := formatting.GetRepoOwnerSplitted(event.URL) + event.Organization = org + event.Repository = repo event.EventType = prAnno[keys.EventType] event.TriggerTarget = triggertype.StringToType(prAnno[keys.EventType]) event.BaseBranch = prAnno[keys.Branch]