mirror of https://github.com/gogs/gogs.git
Merge c18cc1428e
into 4acaaac85a
commit
7ed495fb58
|
@ -119,6 +119,8 @@ ENABLE_RAW_FILE_RENDER_MODE = false
|
|||
COMMITS_FETCH_CONCURRENCY = 0
|
||||
; Default branch name when creating new repositories.
|
||||
DEFAULT_BRANCH = master
|
||||
; Wether to automatically create wiki repos if they do not exist, but are enabled
|
||||
AUTOCREATE_WIKI = true
|
||||
|
||||
[repository.editor]
|
||||
; List of file extensions that should have line wraps in the CodeMirror editor.
|
||||
|
|
|
@ -10,9 +10,11 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gogs/git-module"
|
||||
"github.com/unknwon/com"
|
||||
"github.com/urfave/cli"
|
||||
log "unknwon.dev/clog/v2"
|
||||
|
@ -132,6 +134,8 @@ var allowedCommands = map[string]database.AccessMode{
|
|||
"git-receive-pack": database.AccessModeWrite,
|
||||
}
|
||||
|
||||
var reWikiRepo = regexp.MustCompile("\\.wiki(?:\\.git)?$")
|
||||
|
||||
func runServ(c *cli.Context) error {
|
||||
ctx := context.Background()
|
||||
setup(c, "serv.log", true)
|
||||
|
@ -254,6 +258,17 @@ func runServ(c *cli.Context) error {
|
|||
verb = strings.Replace(verb, "-", " ", 1)
|
||||
}
|
||||
|
||||
repoFsPath := fmt.Sprintf("%s/%s.git", conf.Repository.Root, strings.TrimSuffix(repoFullName, ".git"))
|
||||
if _, err := os.Stat(repoFsPath); err != nil {
|
||||
if conf.Repository.AutocreateWiki && repo.EnableWiki && reWikiRepo.MatchString(repoFullName) && requestMode == db.AccessModeWrite {
|
||||
if err = git.Init(repoFsPath, git.InitOptions{ Bare: true }); err != nil {
|
||||
fail("Internal error", "Failed to initialize new git repo %s: %v", repoFullName, err)
|
||||
}
|
||||
} else {
|
||||
fail("Internal error", "Repository %v doesn't exist!", repoFullName)
|
||||
}
|
||||
}
|
||||
|
||||
var gitCmd *exec.Cmd
|
||||
verbs := strings.Split(verb, " ")
|
||||
if len(verbs) == 2 {
|
||||
|
|
|
@ -323,6 +323,7 @@ type RepositoryOpts struct {
|
|||
EnableRawFileRenderMode bool
|
||||
CommitsFetchConcurrency int
|
||||
DefaultBranch string
|
||||
AutocreateWiki bool
|
||||
|
||||
// Repository editor settings
|
||||
Editor struct {
|
||||
|
|
Loading…
Reference in New Issue