Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions routers/repo/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}

Expand Down Expand Up @@ -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.StatusNotFound, "Repository not found")
return
}

if owner.IsOrganization() && !setting.Repository.EnablePushCreateOrg {
ctx.HandleText(http.StatusForbidden, "Push to create is not enabled for organizations.")
return
Expand Down Expand Up @@ -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}
}
Expand Down