Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-22 01:44:24 +01:00

Fix bug clone wiki (#15499)

Fix #15494

Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
Lunny Xiao 2021-04-16 02:57:19 +08:00 committed by GitHub
parent 8202dd1311
commit 92c09a90f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -103,9 +103,11 @@ func httpBase(ctx *context.Context) (h *serviceHandler) {
isWiki := false isWiki := false
var unitType = models.UnitTypeCode var unitType = models.UnitTypeCode
var wikiRepoName string
if strings.HasSuffix(reponame, ".wiki") { if strings.HasSuffix(reponame, ".wiki") {
isWiki = true isWiki = true
unitType = models.UnitTypeWiki unitType = models.UnitTypeWiki
wikiRepoName = reponame
reponame = reponame[:len(reponame)-5] reponame = reponame[:len(reponame)-5]
} }
@ -314,6 +316,11 @@ func httpBase(ctx *context.Context) (h *serviceHandler) {
return return
} }
if isWiki { // you cannot send wiki operation before create the repository
ctx.HandleText(http.StatusNotFound, "Repository not found")
return
}
if owner.IsOrganization() && !setting.Repository.EnablePushCreateOrg { if owner.IsOrganization() && !setting.Repository.EnablePushCreateOrg {
ctx.HandleText(http.StatusForbidden, "Push to create is not enabled for organizations.") ctx.HandleText(http.StatusForbidden, "Push to create is not enabled for organizations.")
return 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 r.URL.Path = strings.ToLower(r.URL.Path) // blue: In case some repo name has upper case name
dir := models.RepoPath(username, reponame) dir := models.RepoPath(username, reponame)
if isWiki {
dir = models.RepoPath(username, wikiRepoName)
}
return &serviceHandler{cfg, w, r, dir, cfg.Env} return &serviceHandler{cfg, w, r, dir, cfg.Env}
} }