From 869fd17b88ecca1dcf4a0fa925156715aa29a312 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 18 Sep 2020 07:58:04 +0200 Subject: [PATCH] Fix [API] CreateRepo missing information (#12848) (#12867) * Fix [API] [Bug] CreateRepo missing information (#12848) * Fix [API] [Bug] CreateRepo missing information * add code comment Co-authored-by: Lunny Xiao * CI.restart() * CI.restart() Co-authored-by: Lunny Xiao Co-authored-by: zeripath --- routers/api/v1/repo/repo.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index e5055daa2..8a2e3ed6a 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -256,6 +256,12 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR return } + // reload repo from db to get a real state after creation + repo, err = models.GetRepositoryByID(repo.ID) + if err != nil { + ctx.Error(http.StatusInternalServerError, "GetRepositoryByID", err) + } + ctx.JSON(http.StatusCreated, repo.APIFormat(models.AccessModeOwner)) }