From 89fdf2cf589c441a87781dda3e65a69668304c09 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Fri, 16 Apr 2021 00:51:15 +0800 Subject: [PATCH 1/2] Fix bug clone wiki --- routers/repo/http.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/routers/repo/http.go b/routers/repo/http.go index 2b79dddbbd69a..477328ae21443 100644 --- a/routers/repo/http.go +++ b/routers/repo/http.go @@ -103,9 +103,11 @@ func httpBase(ctx *context.Context) (h *serviceHandler) { isWiki := false var unitType = models.UnitTypeCode + var wikiRepoName string if strings.HasSuffix(reponame, ".wiki") { isWiki = true unitType = models.UnitTypeWiki + wikiRepoName = reponame reponame = reponame[:len(reponame)-5] } @@ -314,6 +316,11 @@ func httpBase(ctx *context.Context) (h *serviceHandler) { return } + if isWiki { // you cannot send wiki operation before create the repository + ctx.HandleText(http.StatusForbidden, "Repository not found") + return + } + if owner.IsOrganization() && !setting.Repository.EnablePushCreateOrg { ctx.HandleText(http.StatusForbidden, "Push to create is not enabled for organizations.") return @@ -363,6 +370,9 @@ func httpBase(ctx *context.Context) (h *serviceHandler) { r.URL.Path = strings.ToLower(r.URL.Path) // blue: In case some repo name has upper case name dir := models.RepoPath(username, reponame) + if isWiki { + dir = models.RepoPath(username, wikiRepoName) + } return &serviceHandler{cfg, w, r, dir, cfg.Env} } From 10ce1d654eedce9683134f98a7fc7156c14dec29 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 15 Apr 2021 19:38:09 +0200 Subject: [PATCH 2/2] Update routers/repo/http.go Co-authored-by: Lauris BH --- routers/repo/http.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/repo/http.go b/routers/repo/http.go index 477328ae21443..95a56e4a2c22a 100644 --- a/routers/repo/http.go +++ b/routers/repo/http.go @@ -317,7 +317,7 @@ func httpBase(ctx *context.Context) (h *serviceHandler) { } if isWiki { // you cannot send wiki operation before create the repository - ctx.HandleText(http.StatusForbidden, "Repository not found") + ctx.HandleText(http.StatusNotFound, "Repository not found") return }