mirror of https://github.com/gogs/gogs.git
Option to init empty wiki Git remote repository upon repository creation
This fixes github issue #7226pull/7408/head
parent
5da1e62426
commit
c18cc1428e
|
@ -119,6 +119,8 @@ ENABLE_RAW_FILE_RENDER_MODE = false
|
||||||
COMMITS_FETCH_CONCURRENCY = 0
|
COMMITS_FETCH_CONCURRENCY = 0
|
||||||
; Default branch name when creating new repositories.
|
; Default branch name when creating new repositories.
|
||||||
DEFAULT_BRANCH = master
|
DEFAULT_BRANCH = master
|
||||||
|
; Wether to automatically create wiki repos if they do not exist, but are enabled
|
||||||
|
AUTOCREATE_WIKI = true
|
||||||
|
|
||||||
[repository.editor]
|
[repository.editor]
|
||||||
; List of file extensions that should have line wraps in the CodeMirror editor.
|
; List of file extensions that should have line wraps in the CodeMirror editor.
|
||||||
|
|
|
@ -10,9 +10,11 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/gogs/git-module"
|
||||||
"github.com/unknwon/com"
|
"github.com/unknwon/com"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
log "unknwon.dev/clog/v2"
|
log "unknwon.dev/clog/v2"
|
||||||
|
@ -132,6 +134,8 @@ var allowedCommands = map[string]db.AccessMode{
|
||||||
"git-receive-pack": db.AccessModeWrite,
|
"git-receive-pack": db.AccessModeWrite,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var reWikiRepo = regexp.MustCompile("\\.wiki(?:\\.git)?$")
|
||||||
|
|
||||||
func runServ(c *cli.Context) error {
|
func runServ(c *cli.Context) error {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
setup(c, "serv.log", true)
|
setup(c, "serv.log", true)
|
||||||
|
@ -254,6 +258,17 @@ func runServ(c *cli.Context) error {
|
||||||
verb = strings.Replace(verb, "-", " ", 1)
|
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
|
var gitCmd *exec.Cmd
|
||||||
verbs := strings.Split(verb, " ")
|
verbs := strings.Split(verb, " ")
|
||||||
if len(verbs) == 2 {
|
if len(verbs) == 2 {
|
||||||
|
|
|
@ -323,6 +323,7 @@ type RepositoryOpts struct {
|
||||||
EnableRawFileRenderMode bool
|
EnableRawFileRenderMode bool
|
||||||
CommitsFetchConcurrency int
|
CommitsFetchConcurrency int
|
||||||
DefaultBranch string
|
DefaultBranch string
|
||||||
|
AutocreateWiki bool
|
||||||
|
|
||||||
// Repository editor settings
|
// Repository editor settings
|
||||||
Editor struct {
|
Editor struct {
|
||||||
|
|
Loading…
Reference in New Issue