Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Remove encloding / of the BaseDirectory when creating / updating the project repo setting

天舟40f012c2a016
diff --git a/server/project.go b/server/project.go
index a5b1e37115..c51d30f096 100644
--- a/server/project.go
+++ b/server/project.go
@@ -7,6 +7,7 @@ import (
"fmt"
"net/http"
"strconv"
+ "strings"
"github.com/bytebase/bytebase"
"github.com/bytebase/bytebase/api"
@@ -134,6 +135,8 @@ func (s *Server) registerProjectRoutes(g *echo.Group) {
return echo.NewHTTPError(http.StatusBadRequest, "Malformatted create linked repository request").SetInternal(err)
}
repositoryCreate.CreatorId = c.Get(GetPrincipalIdContextKey()).(int)
+ // Remove enclosing /
+ repositoryCreate.BaseDirectory = strings.Trim(repositoryCreate.BaseDirectory, "/")
repository, err := s.RepositoryService.CreateRepository(context.Background(), repositoryCreate)
if err != nil {
if bytebase.ErrorCode(err) == bytebase.ECONFLICT {
@@ -201,6 +204,11 @@ func (s *Server) registerProjectRoutes(g *echo.Group) {
if err := jsonapi.UnmarshalPayload(c.Request().Body, repositoryPatch); err != nil {
return echo.NewHTTPError(http.StatusBadRequest, "Malformatted patch repository request").SetInternal(err)
}
+ // Remove enclosing /
+ if repositoryPatch.BaseDirectory != nil {
+ baseDir := strings.Trim(*repositoryPatch.BaseDirectory, "/")
+ repositoryPatch.BaseDirectory = &baseDir
+ }
repositoryFind := &api.RepositoryFind{
ProjectId: &projectId,