|
|
@@ -4,6 +4,8 @@ import (
|
|
|
"errors"
|
|
|
"fmt"
|
|
|
"net/http"
|
|
|
+ "net/url"
|
|
|
+ "strings"
|
|
|
"sync"
|
|
|
|
|
|
"github.com/porter-dev/porter/api/server/handlers"
|
|
|
@@ -115,8 +117,21 @@ func (p *GetGitlabRepoBuildpackHandler) ServeHTTP(w http.ResponseWriter, r *http
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ dir, err := url.QueryUnescape(request.Dir)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ p.HandleAPIError(w, r, apierrors.NewErrForbidden(fmt.Errorf("malformed query param dir")))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ dir = strings.TrimPrefix(dir, "./")
|
|
|
+
|
|
|
+ if len(dir) == 0 {
|
|
|
+ dir = "."
|
|
|
+ }
|
|
|
+
|
|
|
tree, resp, err := client.Repositories.ListTree(fmt.Sprintf("%s/%s", owner, name), &gitlab.ListTreeOptions{
|
|
|
- Path: gitlab.String(request.Dir),
|
|
|
+ Path: gitlab.String(dir),
|
|
|
Ref: gitlab.String(branch),
|
|
|
})
|
|
|
|
|
|
@@ -145,7 +160,7 @@ func (p *GetGitlabRepoBuildpackHandler) ServeHTTP(w http.ResponseWriter, r *http
|
|
|
}
|
|
|
}()
|
|
|
buildpacks.Runtimes[idx].DetectGitlab(
|
|
|
- client, tree, owner, name, request.Dir, branch,
|
|
|
+ client, tree, owner, name, dir, branch,
|
|
|
builderInfoMap[buildpacks.PaketoBuilder], builderInfoMap[buildpacks.HerokuBuilder],
|
|
|
)
|
|
|
wg.Done()
|