mirror of https://github.com/gogs/gogs.git
conf: overhaul repository settings (#5932)
parent
f59a68c531
commit
c4a0a40473
|
@ -37,6 +37,8 @@ All notable changes to Gogs are documented in this file.
|
||||||
|
|
||||||
- Configuration option `[other] SHOW_FOOTER_VERSION`
|
- Configuration option `[other] SHOW_FOOTER_VERSION`
|
||||||
- Configuration option `[server] STATIC_ROOT_PATH`
|
- Configuration option `[server] STATIC_ROOT_PATH`
|
||||||
|
- Configuration option `[repository] MIRROR_QUEUE_LENGTH`
|
||||||
|
- Configuration option `[repository] PULL_REQUEST_QUEUE_LENGTH`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
53
conf/app.ini
53
conf/app.ini
|
@ -89,53 +89,48 @@ RSA = 2048
|
||||||
DSA = 1024
|
DSA = 1024
|
||||||
|
|
||||||
[repository]
|
[repository]
|
||||||
; Root path for storing repositories's data, default is "~/gogs-repositories"
|
; The root path for storing managed repositories, default is "~/gogs-repositories"
|
||||||
ROOT =
|
ROOT =
|
||||||
; The script type server supports, sometimes could be "sh"
|
; The script type server supports, sometimes could be "sh".
|
||||||
SCRIPT_TYPE = bash
|
SCRIPT_TYPE = bash
|
||||||
; Default ANSI charset for an unrecognized charset
|
; Default ANSI charset for an unrecognized charset.
|
||||||
ANSI_CHARSET =
|
ANSI_CHARSET =
|
||||||
; Force every new repository to be private
|
; Whether to force every new repository to be private.
|
||||||
FORCE_PRIVATE = false
|
FORCE_PRIVATE = false
|
||||||
; Global maximum creation limit of repository per user, -1 means no limit
|
; The global limit of number of repositories a user can create, -1 means no limit.
|
||||||
MAX_CREATION_LIMIT = -1
|
MAX_CREATION_LIMIT = -1
|
||||||
; Mirror sync queue length, increase if mirror syncing starts hanging
|
; Preferred Licenses to place at the top of the list.
|
||||||
MIRROR_QUEUE_LENGTH = 1000
|
; Name must match file name in "conf/license" or "custom/conf/license".
|
||||||
; Patch test queue length, increase if pull request patch testing starts hanging
|
PREFERRED_LICENSES = Apache License 2.0, MIT License
|
||||||
PULL_REQUEST_QUEUE_LENGTH = 1000
|
; Whether to disable Git interaction with repositories via HTTP/HTTPS protocol.
|
||||||
; Preferred Licenses to place at the top of the list
|
|
||||||
; Name must match file name in conf/license or custom/conf/license
|
|
||||||
PREFERRED_LICENSES = Apache License 2.0,MIT License
|
|
||||||
; Disable ability to interact with repositories by HTTP protocol
|
|
||||||
DISABLE_HTTP_GIT = false
|
DISABLE_HTTP_GIT = false
|
||||||
; Enable ability to migrate repository by local path
|
; Whether to enable ability to migrate repository by server local path.
|
||||||
ENABLE_LOCAL_PATH_MIGRATION = false
|
ENABLE_LOCAL_PATH_MIGRATION = false
|
||||||
; Concurrency is used to retrieve commits information. This variable define
|
; Whether to enable render mode for raw file. There are potential security risks.
|
||||||
; the maximum number of tasks that can be run at the same time. Usually, the
|
|
||||||
; value depend of how many CPUs (cores) you have. If the value is set to zero
|
|
||||||
; or under, Gogs will automatically detect the number of CPUs your system have
|
|
||||||
COMMITS_FETCH_CONCURRENCY = 0
|
|
||||||
; Enable render mode for raw file
|
|
||||||
ENABLE_RAW_FILE_RENDER_MODE = false
|
ENABLE_RAW_FILE_RENDER_MODE = false
|
||||||
|
; The maximum number of goroutines that can be run at the same time for a single
|
||||||
|
; fetch request. Usually, the value depend of how many CPU (cores) you have. If
|
||||||
|
; the value is non-positive, it matchs the number of CPUs available to the application.
|
||||||
|
COMMITS_FETCH_CONCURRENCY = 0
|
||||||
|
|
||||||
[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.
|
||||||
; Separate extensions with a comma. To line wrap files without extension, just put a comma
|
; Separate extensions with a comma.
|
||||||
LINE_WRAP_EXTENSIONS = .txt,.md,.markdown,.mdown,.mkd,
|
LINE_WRAP_EXTENSIONS = .txt,.md,.markdown,.mdown,.mkd
|
||||||
; Valid file modes that have a preview API associated with them, such as api/v1/markdown.
|
; Valid file modes that have a preview API associated with them, such as "/api/v1/markdown".
|
||||||
; Separate values by commas. Preview tab in edit mode won't show if the file extension doesn't match
|
; Separate values by commas. Preview tab in edit mode won't show if the file extension doesn't match.
|
||||||
PREVIEWABLE_FILE_MODES = markdown
|
PREVIEWABLE_FILE_MODES = markdown
|
||||||
|
|
||||||
[repository.upload]
|
[repository.upload]
|
||||||
; Enable repository file uploads.
|
; Whether to enable repository file uploads.
|
||||||
ENABLED = true
|
ENABLED = true
|
||||||
; Path to temporarily store uploads (default path gets cleaned by Gogs in every start)
|
; The path to temporarily store uploads (content under this path gets wiped out on every start).
|
||||||
TEMP_PATH = data/tmp/uploads
|
TEMP_PATH = data/tmp/uploads
|
||||||
; File types that are allowed to be uploaded, e.g. image/jpeg|image/png. Leave empty means allow any file type
|
; File types that are allowed to be uploaded, e.g. "image/jpeg|image/png". Leave empty to allow any file type.
|
||||||
ALLOWED_TYPES =
|
ALLOWED_TYPES =
|
||||||
; Maximum size of each file in MB
|
; The maximum size of each file in MB.
|
||||||
FILE_MAX_SIZE = 3
|
FILE_MAX_SIZE = 3
|
||||||
; Maximum number of files per upload
|
; The maximum number of files per upload.
|
||||||
MAX_FILES = 5
|
MAX_FILES = 5
|
||||||
|
|
||||||
; Attachment settings for releases
|
; Attachment settings for releases
|
||||||
|
|
|
@ -1197,19 +1197,28 @@ config.ssh.listen_host = Listen host
|
||||||
config.ssh.listen_port = Listen port
|
config.ssh.listen_port = Listen port
|
||||||
config.ssh.server_ciphers = Server ciphers
|
config.ssh.server_ciphers = Server ciphers
|
||||||
|
|
||||||
|
config.repo_config = Repository configuration
|
||||||
|
config.repo.root_path = Root path
|
||||||
|
config.repo.script_type = Script type
|
||||||
|
config.repo.ansi_chatset = ANSI charset
|
||||||
|
config.repo.force_private = Force private
|
||||||
|
config.repo.max_creation_limit = Max creation limit
|
||||||
|
config.repo.preferred_licenses = Preferred licenses
|
||||||
|
config.repo.disable_http_git = Disable HTTP Git
|
||||||
|
config.repo.enable_local_path_migration = Enable local path migration
|
||||||
|
config.repo.enable_raw_file_render_mode = Enable raw file render mode
|
||||||
|
config.repo.commits_fetch_concurrency = Commits fetch concurrency
|
||||||
|
config.repo.editor.line_wrap_extensions = Editor line wrap extensions
|
||||||
|
config.repo.editor.previewable_file_modes = Editor previewable file modes
|
||||||
|
config.repo.upload.enabled = Upload enabled
|
||||||
|
config.repo.upload.temp_path = Upload temporary path
|
||||||
|
config.repo.upload.allowed_types = Upload allowed types
|
||||||
|
config.repo.upload.file_max_size = Upload file size limit
|
||||||
|
config.repo.upload.max_files = Upload files limit
|
||||||
|
|
||||||
config.log_file_root_path = Log File Root Path
|
config.log_file_root_path = Log File Root Path
|
||||||
config.reverse_auth_user = Reverse Authentication User
|
config.reverse_auth_user = Reverse Authentication User
|
||||||
|
|
||||||
config.repo_config = Repository Configuration
|
|
||||||
config.repo_root_path = Repository Root Path
|
|
||||||
config.script_type = Script Type
|
|
||||||
config.repo_force_private = Force Private
|
|
||||||
config.max_creation_limit = Max Creation Limit
|
|
||||||
config.preferred_licenses = Preferred Licenses
|
|
||||||
config.disable_http_git = Disable HTTP Git
|
|
||||||
config.enable_local_path_migration = Enable Local Path Migration
|
|
||||||
config.commits_fetch_concurrency = Commits Fetch Concurrency
|
|
||||||
|
|
||||||
config.http_config = HTTP Configuration
|
config.http_config = HTTP Configuration
|
||||||
config.http_access_control_allow_origin = Access Control Allow Origin
|
config.http_access_control_allow_origin = Access Control Allow Origin
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -119,8 +119,8 @@ func runBackup(c *cli.Context) error {
|
||||||
// Repositories
|
// Repositories
|
||||||
if !c.Bool("exclude-repos") && !c.Bool("database-only") {
|
if !c.Bool("exclude-repos") && !c.Bool("database-only") {
|
||||||
reposDump := filepath.Join(rootDir, "repositories.zip")
|
reposDump := filepath.Join(rootDir, "repositories.zip")
|
||||||
log.Info("Dumping repositories in '%s'", conf.RepoRootPath)
|
log.Info("Dumping repositories in %q", conf.Repository.Root)
|
||||||
if err = zip.PackTo(conf.RepoRootPath, reposDump, true); err != nil {
|
if err = zip.PackTo(conf.Repository.Root, reposDump, true); err != nil {
|
||||||
log.Fatal("Failed to dump repositories: %v", err)
|
log.Fatal("Failed to dump repositories: %v", err)
|
||||||
}
|
}
|
||||||
log.Info("Repositories dumped to: %s", reposDump)
|
log.Info("Repositories dumped to: %s", reposDump)
|
||||||
|
|
|
@ -145,7 +145,7 @@ func runRestore(c *cli.Context) error {
|
||||||
// Repositories
|
// Repositories
|
||||||
reposPath := filepath.Join(archivePath, "repositories.zip")
|
reposPath := filepath.Join(archivePath, "repositories.zip")
|
||||||
if !c.Bool("exclude-repos") && !c.Bool("database-only") && com.IsExist(reposPath) {
|
if !c.Bool("exclude-repos") && !c.Bool("database-only") && com.IsExist(reposPath) {
|
||||||
if err := zip.ExtractTo(reposPath, filepath.Dir(conf.RepoRootPath)); err != nil {
|
if err := zip.ExtractTo(reposPath, filepath.Dir(conf.Repository.Root)); err != nil {
|
||||||
log.Fatal("Failed to extract 'repositories.zip': %v", err)
|
log.Fatal("Failed to extract 'repositories.zip': %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,7 +267,7 @@ func runServ(c *cli.Context) error {
|
||||||
RepoPath: repo.RepoPath(),
|
RepoPath: repo.RepoPath(),
|
||||||
})...)
|
})...)
|
||||||
}
|
}
|
||||||
gitCmd.Dir = conf.RepoRootPath
|
gitCmd.Dir = conf.Repository.Root
|
||||||
gitCmd.Stdout = os.Stdout
|
gitCmd.Stdout = os.Stdout
|
||||||
gitCmd.Stdin = os.Stdin
|
gitCmd.Stdin = os.Stdin
|
||||||
gitCmd.Stderr = os.Stderr
|
gitCmd.Stderr = os.Stderr
|
||||||
|
|
|
@ -100,6 +100,7 @@ func Init(customConf string) error {
|
||||||
if err = File.Section("server").MapTo(&Server); err != nil {
|
if err = File.Section("server").MapTo(&Server); err != nil {
|
||||||
return errors.Wrap(err, "mapping [server] section")
|
return errors.Wrap(err, "mapping [server] section")
|
||||||
}
|
}
|
||||||
|
Server.AppDataPath = ensureAbs(Server.AppDataPath)
|
||||||
|
|
||||||
if !strings.HasSuffix(Server.ExternalURL, "/") {
|
if !strings.HasSuffix(Server.ExternalURL, "/") {
|
||||||
Server.ExternalURL += "/"
|
Server.ExternalURL += "/"
|
||||||
|
@ -122,22 +123,19 @@ func Init(customConf string) error {
|
||||||
}
|
}
|
||||||
Server.UnixSocketMode = os.FileMode(unixSocketMode)
|
Server.UnixSocketMode = os.FileMode(unixSocketMode)
|
||||||
|
|
||||||
if !filepath.IsAbs(Server.AppDataPath) {
|
|
||||||
Server.AppDataPath = filepath.Join(WorkDir(), Server.AppDataPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ************************
|
// ************************
|
||||||
// ----- SSH settings -----
|
// ----- SSH settings -----
|
||||||
// ************************
|
// ************************
|
||||||
|
|
||||||
|
SSH.RootPath = filepath.Join(HomeDir(), ".ssh")
|
||||||
|
SSH.KeyTestPath = os.TempDir()
|
||||||
if err = File.Section("server").MapTo(&SSH); err != nil {
|
if err = File.Section("server").MapTo(&SSH); err != nil {
|
||||||
return errors.Wrap(err, "mapping SSH settings from [server] section")
|
return errors.Wrap(err, "mapping SSH settings from [server] section")
|
||||||
}
|
}
|
||||||
|
SSH.RootPath = ensureAbs(SSH.RootPath)
|
||||||
|
SSH.KeyTestPath = ensureAbs(SSH.KeyTestPath)
|
||||||
|
|
||||||
if !SSH.Disabled {
|
if !SSH.Disabled {
|
||||||
SSH.RootPath = filepath.Join(HomeDir(), ".ssh")
|
|
||||||
SSH.KeyTestPath = os.TempDir()
|
|
||||||
|
|
||||||
if !SSH.StartBuiltinServer {
|
if !SSH.StartBuiltinServer {
|
||||||
if err := os.MkdirAll(SSH.RootPath, 0700); err != nil {
|
if err := os.MkdirAll(SSH.RootPath, 0700); err != nil {
|
||||||
return errors.Wrap(err, "create SSH root directory")
|
return errors.Wrap(err, "create SSH root directory")
|
||||||
|
@ -173,7 +171,18 @@ func Init(customConf string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
transferDeprecated()
|
// *******************************
|
||||||
|
// ----- Repository settings -----
|
||||||
|
// *******************************
|
||||||
|
|
||||||
|
Repository.Root = filepath.Join(HomeDir(), "gogs-repositories")
|
||||||
|
if err = File.Section("repository").MapTo(&Repository); err != nil {
|
||||||
|
return errors.Wrap(err, "mapping [repository] section")
|
||||||
|
}
|
||||||
|
Repository.Root = ensureAbs(Repository.Root)
|
||||||
|
Repository.Upload.TempPath = ensureAbs(Repository.Upload.TempPath)
|
||||||
|
|
||||||
|
handleDeprecated()
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
|
@ -224,27 +233,6 @@ func Init(customConf string) error {
|
||||||
"StampNano": time.StampNano,
|
"StampNano": time.StampNano,
|
||||||
}[File.Section("time").Key("FORMAT").MustString("RFC1123")]
|
}[File.Section("time").Key("FORMAT").MustString("RFC1123")]
|
||||||
|
|
||||||
// Determine and create root git repository path.
|
|
||||||
sec = File.Section("repository")
|
|
||||||
RepoRootPath = sec.Key("ROOT").MustString(filepath.Join(HomeDir(), "gogs-repositories"))
|
|
||||||
if !filepath.IsAbs(RepoRootPath) {
|
|
||||||
RepoRootPath = path.Join(workDir, RepoRootPath)
|
|
||||||
} else {
|
|
||||||
RepoRootPath = path.Clean(RepoRootPath)
|
|
||||||
}
|
|
||||||
ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash")
|
|
||||||
if err = File.Section("repository").MapTo(&Repository); err != nil {
|
|
||||||
log.Fatal("Failed to map Repository settings: %v", err)
|
|
||||||
} else if err = File.Section("repository.editor").MapTo(&Repository.Editor); err != nil {
|
|
||||||
log.Fatal("Failed to map Repository.Editor settings: %v", err)
|
|
||||||
} else if err = File.Section("repository.upload").MapTo(&Repository.Upload); err != nil {
|
|
||||||
log.Fatal("Failed to map Repository.Upload settings: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !filepath.IsAbs(Repository.Upload.TempPath) {
|
|
||||||
Repository.Upload.TempPath = path.Join(workDir, Repository.Upload.TempPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
sec = File.Section("picture")
|
sec = File.Section("picture")
|
||||||
AvatarUploadPath = sec.Key("AVATAR_UPLOAD_PATH").MustString(filepath.Join(Server.AppDataPath, "avatars"))
|
AvatarUploadPath = sec.Key("AVATAR_UPLOAD_PATH").MustString(filepath.Join(Server.AppDataPath, "avatars"))
|
||||||
if !filepath.IsAbs(AvatarUploadPath) {
|
if !filepath.IsAbs(AvatarUploadPath) {
|
||||||
|
@ -361,37 +349,6 @@ var (
|
||||||
UsePostgreSQL bool
|
UsePostgreSQL bool
|
||||||
UseMSSQL bool
|
UseMSSQL bool
|
||||||
|
|
||||||
// Repository settings
|
|
||||||
Repository struct {
|
|
||||||
AnsiCharset string
|
|
||||||
ForcePrivate bool
|
|
||||||
MaxCreationLimit int
|
|
||||||
MirrorQueueLength int
|
|
||||||
PullRequestQueueLength int
|
|
||||||
PreferredLicenses []string
|
|
||||||
DisableHTTPGit bool `ini:"DISABLE_HTTP_GIT"`
|
|
||||||
EnableLocalPathMigration bool
|
|
||||||
CommitsFetchConcurrency int
|
|
||||||
EnableRawFileRenderMode bool
|
|
||||||
|
|
||||||
// Repository editor settings
|
|
||||||
Editor struct {
|
|
||||||
LineWrapExtensions []string
|
|
||||||
PreviewableFileModes []string
|
|
||||||
} `ini:"-"`
|
|
||||||
|
|
||||||
// Repository upload settings
|
|
||||||
Upload struct {
|
|
||||||
Enabled bool
|
|
||||||
TempPath string
|
|
||||||
AllowedTypes []string `delim:"|"`
|
|
||||||
FileMaxSize int64
|
|
||||||
MaxFiles int
|
|
||||||
} `ini:"-"`
|
|
||||||
}
|
|
||||||
RepoRootPath string
|
|
||||||
ScriptType string
|
|
||||||
|
|
||||||
// Webhook settings
|
// Webhook settings
|
||||||
Webhook struct {
|
Webhook struct {
|
||||||
Types []string
|
Types []string
|
||||||
|
|
|
@ -12,9 +12,13 @@ import (
|
||||||
// ℹ️ README: This file contains static values that should only be set at initialization time.
|
// ℹ️ README: This file contains static values that should only be set at initialization time.
|
||||||
|
|
||||||
// HasMinWinSvc is whether the application is built with Windows Service support.
|
// HasMinWinSvc is whether the application is built with Windows Service support.
|
||||||
|
//
|
||||||
|
// ⚠️ WARNING: should only be set by "static_minwinsvc.go".
|
||||||
var HasMinWinSvc bool
|
var HasMinWinSvc bool
|
||||||
|
|
||||||
// Build information should only be set by -ldflags.
|
// Build time and commit information.
|
||||||
|
//
|
||||||
|
// ⚠️ WARNING: should only be set by -ldflags.
|
||||||
var (
|
var (
|
||||||
BuildTime string
|
BuildTime string
|
||||||
BuildCommit string
|
BuildCommit string
|
||||||
|
@ -28,7 +32,7 @@ var CustomConf string
|
||||||
var (
|
var (
|
||||||
// Application settings
|
// Application settings
|
||||||
App struct {
|
App struct {
|
||||||
// ⚠️ WARNING: Should only be set by gogs.go.
|
// ⚠️ WARNING: Should only be set by main package (i.e. "gogs.go").
|
||||||
Version string `ini:"-"`
|
Version string `ini:"-"`
|
||||||
|
|
||||||
BrandName string
|
BrandName string
|
||||||
|
@ -90,10 +94,39 @@ var (
|
||||||
ListenPort int `ini:"SSH_LISTEN_PORT"`
|
ListenPort int `ini:"SSH_LISTEN_PORT"`
|
||||||
ServerCiphers []string `ini:"SSH_SERVER_CIPHERS"`
|
ServerCiphers []string `ini:"SSH_SERVER_CIPHERS"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Repository settings
|
||||||
|
Repository struct {
|
||||||
|
Root string
|
||||||
|
ScriptType string
|
||||||
|
ANSICharset string `ini:"ANSI_CHARSET"`
|
||||||
|
ForcePrivate bool
|
||||||
|
MaxCreationLimit int
|
||||||
|
PreferredLicenses []string
|
||||||
|
DisableHTTPGit bool `ini:"DISABLE_HTTP_GIT"`
|
||||||
|
EnableLocalPathMigration bool
|
||||||
|
EnableRawFileRenderMode bool
|
||||||
|
CommitsFetchConcurrency int
|
||||||
|
|
||||||
|
// Repository editor settings
|
||||||
|
Editor struct {
|
||||||
|
LineWrapExtensions []string
|
||||||
|
PreviewableFileModes []string
|
||||||
|
} `ini:"repository.editor"`
|
||||||
|
|
||||||
|
// Repository upload settings
|
||||||
|
Upload struct {
|
||||||
|
Enabled bool
|
||||||
|
TempPath string
|
||||||
|
AllowedTypes []string `delim:"|"`
|
||||||
|
FileMaxSize int64
|
||||||
|
MaxFiles int
|
||||||
|
} `ini:"repository.upload"`
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// transferDeprecated transfers deprecated values to the new ones when set.
|
// handleDeprecated transfers deprecated values to the new ones when set.
|
||||||
func transferDeprecated() {
|
func handleDeprecated() {
|
||||||
if App.AppName != "" {
|
if App.AppName != "" {
|
||||||
App.BrandName = App.AppName
|
App.BrandName = App.AppName
|
||||||
App.AppName = ""
|
App.AppName = ""
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
package conf
|
package conf
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
@ -25,3 +26,11 @@ func openSSHVersion() (string, error) {
|
||||||
v = strings.TrimSuffix(strings.TrimPrefix(v, "OpenSSH_"), "p")
|
v = strings.TrimSuffix(strings.TrimPrefix(v, "OpenSSH_"), "p")
|
||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ensureAbs prepends the WorkDir to the given path if it is not an absolute path.
|
||||||
|
func ensureAbs(path string) string {
|
||||||
|
if filepath.IsAbs(path) {
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
return filepath.Join(WorkDir(), path)
|
||||||
|
}
|
||||||
|
|
|
@ -32,9 +32,9 @@ func generateAndMigrateGitHooks(x *xorm.Engine) (err error) {
|
||||||
var (
|
var (
|
||||||
hookNames = []string{"pre-receive", "update", "post-receive"}
|
hookNames = []string{"pre-receive", "update", "post-receive"}
|
||||||
hookTpls = []string{
|
hookTpls = []string{
|
||||||
fmt.Sprintf("#!/usr/bin/env %s\n\"%s\" hook --config='%s' pre-receive\n", conf.ScriptType, conf.AppPath(), conf.CustomConf),
|
fmt.Sprintf("#!/usr/bin/env %s\n\"%s\" hook --config='%s' pre-receive\n", conf.Repository.ScriptType, conf.AppPath(), conf.CustomConf),
|
||||||
fmt.Sprintf("#!/usr/bin/env %s\n\"%s\" hook --config='%s' update $1 $2 $3\n", conf.ScriptType, conf.AppPath(), conf.CustomConf),
|
fmt.Sprintf("#!/usr/bin/env %s\n\"%s\" hook --config='%s' update $1 $2 $3\n", conf.Repository.ScriptType, conf.AppPath(), conf.CustomConf),
|
||||||
fmt.Sprintf("#!/usr/bin/env %s\n\"%s\" hook --config='%s' post-receive\n", conf.ScriptType, conf.AppPath(), conf.CustomConf),
|
fmt.Sprintf("#!/usr/bin/env %s\n\"%s\" hook --config='%s' post-receive\n", conf.Repository.ScriptType, conf.AppPath(), conf.CustomConf),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ func generateAndMigrateGitHooks(x *xorm.Engine) (err error) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
repoBase := filepath.Join(conf.RepoRootPath, strings.ToLower(user.Name), strings.ToLower(repo.Name))
|
repoBase := filepath.Join(conf.Repository.Root, strings.ToLower(user.Name), strings.ToLower(repo.Name))
|
||||||
repoPath := repoBase + ".git"
|
repoPath := repoBase + ".git"
|
||||||
wikiPath := repoBase + ".wiki.git"
|
wikiPath := repoBase + ".wiki.git"
|
||||||
log.Trace("[%04d]: %s", idx, repoPath)
|
log.Trace("[%04d]: %s", idx, repoPath)
|
||||||
|
|
|
@ -60,7 +60,7 @@ func updateRepositorySizes(x *xorm.Engine) (err error) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
repoPath := filepath.Join(conf.RepoRootPath, strings.ToLower(user.Name), strings.ToLower(repo.Name)) + ".git"
|
repoPath := filepath.Join(conf.Repository.Root, strings.ToLower(user.Name), strings.ToLower(repo.Name)) + ".git"
|
||||||
countObject, err := git.GetRepoSize(repoPath)
|
countObject, err := git.GetRepoSize(repoPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("GetRepoSize: %v", err)
|
log.Warn("GetRepoSize: %v", err)
|
||||||
|
|
|
@ -18,13 +18,13 @@ import (
|
||||||
|
|
||||||
"github.com/gogs/git-module"
|
"github.com/gogs/git-module"
|
||||||
|
|
||||||
|
"gogs.io/gogs/internal/conf"
|
||||||
"gogs.io/gogs/internal/db/errors"
|
"gogs.io/gogs/internal/db/errors"
|
||||||
"gogs.io/gogs/internal/process"
|
"gogs.io/gogs/internal/process"
|
||||||
"gogs.io/gogs/internal/conf"
|
|
||||||
"gogs.io/gogs/internal/sync"
|
"gogs.io/gogs/internal/sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
var MirrorQueue = sync.NewUniqueQueue(conf.Repository.MirrorQueueLength)
|
var MirrorQueue = sync.NewUniqueQueue(1000)
|
||||||
|
|
||||||
// Mirror represents mirror information of a repository.
|
// Mirror represents mirror information of a repository.
|
||||||
type Mirror struct {
|
type Mirror struct {
|
||||||
|
|
|
@ -26,7 +26,7 @@ import (
|
||||||
"gogs.io/gogs/internal/sync"
|
"gogs.io/gogs/internal/sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
var PullRequestQueue = sync.NewUniqueQueue(conf.Repository.PullRequestQueueLength)
|
var PullRequestQueue = sync.NewUniqueQueue(1000)
|
||||||
|
|
||||||
type PullRequestType int
|
type PullRequestType int
|
||||||
|
|
||||||
|
|
|
@ -857,7 +857,7 @@ func createDelegateHooks(repoPath string) (err error) {
|
||||||
for _, name := range git.HookNames {
|
for _, name := range git.HookNames {
|
||||||
hookPath := filepath.Join(repoPath, "hooks", name)
|
hookPath := filepath.Join(repoPath, "hooks", name)
|
||||||
if err = ioutil.WriteFile(hookPath,
|
if err = ioutil.WriteFile(hookPath,
|
||||||
[]byte(fmt.Sprintf(hooksTpls[name], conf.ScriptType, conf.AppPath(), conf.CustomConf)),
|
[]byte(fmt.Sprintf(hooksTpls[name], conf.Repository.ScriptType, conf.AppPath(), conf.CustomConf)),
|
||||||
os.ModePerm); err != nil {
|
os.ModePerm); err != nil {
|
||||||
return fmt.Errorf("create delegate hook '%s': %v", hookPath, err)
|
return fmt.Errorf("create delegate hook '%s': %v", hookPath, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -877,7 +877,7 @@ func DeleteInactivateUsers() (err error) {
|
||||||
|
|
||||||
// UserPath returns the path absolute path of user repositories.
|
// UserPath returns the path absolute path of user repositories.
|
||||||
func UserPath(userName string) string {
|
func UserPath(userName string) string {
|
||||||
return filepath.Join(conf.RepoRootPath, strings.ToLower(userName))
|
return filepath.Join(conf.Repository.Root, strings.ToLower(userName))
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetUserByKeyID(keyID int64) (*User, error) {
|
func GetUserByKeyID(keyID int64) (*User, error) {
|
||||||
|
|
|
@ -199,13 +199,11 @@ func Config(c *context.Context) {
|
||||||
c.Data["App"] = conf.App
|
c.Data["App"] = conf.App
|
||||||
c.Data["Server"] = conf.Server
|
c.Data["Server"] = conf.Server
|
||||||
c.Data["SSH"] = conf.SSH
|
c.Data["SSH"] = conf.SSH
|
||||||
|
c.Data["Repository"] = conf.Repository
|
||||||
|
|
||||||
c.Data["LogRootPath"] = conf.LogRootPath
|
c.Data["LogRootPath"] = conf.LogRootPath
|
||||||
c.Data["ReverseProxyAuthUser"] = conf.ReverseProxyAuthUser
|
c.Data["ReverseProxyAuthUser"] = conf.ReverseProxyAuthUser
|
||||||
|
|
||||||
c.Data["RepoRootPath"] = conf.RepoRootPath
|
|
||||||
c.Data["ScriptType"] = conf.ScriptType
|
|
||||||
c.Data["Repository"] = conf.Repository
|
|
||||||
c.Data["HTTP"] = conf.HTTP
|
c.Data["HTTP"] = conf.HTTP
|
||||||
|
|
||||||
c.Data["DbCfg"] = db.DbCfg
|
c.Data["DbCfg"] = db.DbCfg
|
||||||
|
|
|
@ -155,7 +155,7 @@ func Install(c *context.Context) {
|
||||||
|
|
||||||
// Application general settings
|
// Application general settings
|
||||||
f.AppName = conf.App.BrandName
|
f.AppName = conf.App.BrandName
|
||||||
f.RepoRootPath = conf.RepoRootPath
|
f.RepoRootPath = conf.Repository.Root
|
||||||
|
|
||||||
// Note(unknwon): it's hard for Windows users change a running user,
|
// Note(unknwon): it's hard for Windows users change a running user,
|
||||||
// so just use current one if config says default.
|
// so just use current one if config says default.
|
||||||
|
|
|
@ -19,11 +19,11 @@ import (
|
||||||
"gopkg.in/macaron.v1"
|
"gopkg.in/macaron.v1"
|
||||||
log "unknwon.dev/clog/v2"
|
log "unknwon.dev/clog/v2"
|
||||||
|
|
||||||
|
"gogs.io/gogs/internal/conf"
|
||||||
"gogs.io/gogs/internal/context"
|
"gogs.io/gogs/internal/context"
|
||||||
"gogs.io/gogs/internal/db"
|
"gogs.io/gogs/internal/db"
|
||||||
"gogs.io/gogs/internal/db/errors"
|
"gogs.io/gogs/internal/db/errors"
|
||||||
"gogs.io/gogs/internal/lazyregexp"
|
"gogs.io/gogs/internal/lazyregexp"
|
||||||
"gogs.io/gogs/internal/conf"
|
|
||||||
"gogs.io/gogs/internal/tool"
|
"gogs.io/gogs/internal/tool"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -368,7 +368,7 @@ func getGitRepoPath(dir string) (string, error) {
|
||||||
dir += ".git"
|
dir += ".git"
|
||||||
}
|
}
|
||||||
|
|
||||||
filename := path.Join(conf.RepoRootPath, dir)
|
filename := path.Join(conf.Repository.Root, dir)
|
||||||
if _, err := os.Stat(filename); os.IsNotExist(err) {
|
if _, err := os.Stat(filename); os.IsNotExist(err) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,9 +62,9 @@ func DetectEncoding(content []byte) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := chardet.NewTextDetector().DetectBest(content)
|
result, err := chardet.NewTextDetector().DetectBest(content)
|
||||||
if result.Charset != "UTF-8" && len(conf.Repository.AnsiCharset) > 0 {
|
if result.Charset != "UTF-8" && len(conf.Repository.ANSICharset) > 0 {
|
||||||
log.Trace("Using default AnsiCharset: %s", conf.Repository.AnsiCharset)
|
log.Trace("Using default ANSICharset: %s", conf.Repository.ANSICharset)
|
||||||
return conf.Repository.AnsiCharset, err
|
return conf.Repository.ANSICharset, err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Trace("Detected encoding: %s", result.Charset)
|
log.Trace("Detected encoding: %s", result.Charset)
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
{{template "admin/navbar" .}}
|
{{template "admin/navbar" .}}
|
||||||
<div class="twelve wide column content">
|
<div class="twelve wide column content">
|
||||||
{{template "base/alert" .}}
|
{{template "base/alert" .}}
|
||||||
|
|
||||||
|
{{/* Server settings */}}
|
||||||
<h4 class="ui top attached header">
|
<h4 class="ui top attached header">
|
||||||
{{.i18n.Tr "admin.config.server_config"}}
|
{{.i18n.Tr "admin.config.server_config"}}
|
||||||
</h4>
|
</h4>
|
||||||
|
@ -70,6 +72,7 @@
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{/* SSH settings */}}
|
||||||
<h4 class="ui top attached header">
|
<h4 class="ui top attached header">
|
||||||
{{.i18n.Tr "admin.config.ssh_config"}}
|
{{.i18n.Tr "admin.config.ssh_config"}}
|
||||||
</h4>
|
</h4>
|
||||||
|
@ -109,28 +112,52 @@
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Repository Configuration -->
|
{{/* Repository settings */}}
|
||||||
<h4 class="ui top attached header">
|
<h4 class="ui top attached header">
|
||||||
{{.i18n.Tr "admin.config.repo_config"}}
|
{{.i18n.Tr "admin.config.repo_config"}}
|
||||||
</h4>
|
</h4>
|
||||||
<div class="ui attached table segment">
|
<div class="ui attached table segment">
|
||||||
<dl class="dl-horizontal admin-dl-horizontal">
|
<dl class="dl-horizontal admin-dl-horizontal">
|
||||||
<dt>{{.i18n.Tr "admin.config.repo_root_path"}}</dt>
|
<dt>{{.i18n.Tr "admin.config.repo.root_path"}}</dt>
|
||||||
<dd><code>{{.RepoRootPath}}</code></dd>
|
<dd><code>{{.Repository.Root}}</code></dd>
|
||||||
<dt>{{.i18n.Tr "admin.config.script_type"}}</dt>
|
<dt>{{.i18n.Tr "admin.config.repo.script_type"}}</dt>
|
||||||
<dd>{{.ScriptType}}</dd>
|
<dd><code>{{.Repository.ScriptType}}</code></dd>
|
||||||
<dt>{{.i18n.Tr "admin.config.repo_force_private"}}</dt>
|
<dt>{{.i18n.Tr "admin.config.repo.ansi_chatset"}}</dt>
|
||||||
|
<dd>{{if .Repository.ANSICharset}}{{.Repository.AnsiCharset}}{{else}}{{.i18n.Tr "admin.config.not_set"}}{{end}}</dd>
|
||||||
|
<dt>{{.i18n.Tr "admin.config.repo.force_private"}}</dt>
|
||||||
<dd><i class="fa fa{{if .Repository.ForcePrivate}}-check{{end}}-square-o"></i></dd>
|
<dd><i class="fa fa{{if .Repository.ForcePrivate}}-check{{end}}-square-o"></i></dd>
|
||||||
<dt>{{.i18n.Tr "admin.config.max_creation_limit"}}</dt>
|
<dt>{{.i18n.Tr "admin.config.repo.max_creation_limit"}}</dt>
|
||||||
<dd>{{.Repository.MaxCreationLimit}}</dd>
|
<dd>{{.Repository.MaxCreationLimit}}</dd>
|
||||||
<dt>{{.i18n.Tr "admin.config.preferred_licenses"}}</dt>
|
<dt>{{.i18n.Tr "admin.config.repo.preferred_licenses"}}</dt>
|
||||||
<dd>{{Join .Repository.PreferredLicenses ", "}}</dd>
|
<dd>{{Join .Repository.PreferredLicenses ", "}}</dd>
|
||||||
<dt>{{.i18n.Tr "admin.config.disable_http_git"}}</dt>
|
<dt>{{.i18n.Tr "admin.config.repo.disable_http_git"}}</dt>
|
||||||
<dd><i class="fa fa{{if .Repository.DisableHTTPGit}}-check{{end}}-square-o"></i></dd>
|
<dd><i class="fa fa{{if .Repository.DisableHTTPGit}}-check{{end}}-square-o"></i></dd>
|
||||||
<dt>{{.i18n.Tr "admin.config.enable_local_path_migration"}}</dt>
|
<dt>{{.i18n.Tr "admin.config.repo.enable_local_path_migration"}}</dt>
|
||||||
<dd><i class="fa fa{{if .Repository.EnableLocalPathMigration}}-check{{end}}-square-o"></i></dd>
|
<dd><i class="fa fa{{if .Repository.EnableLocalPathMigration}}-check{{end}}-square-o"></i></dd>
|
||||||
<dt>{{.i18n.Tr "admin.config.commits_fetch_concurrency"}}</dt>
|
<dt>{{.i18n.Tr "admin.config.repo.enable_raw_file_render_mode"}}</dt>
|
||||||
|
<dd><i class="fa fa{{if .Repository.EnableRawFileRenderMode}}-check{{end}}-square-o"></i></dd>
|
||||||
|
<dt>{{.i18n.Tr "admin.config.repo.commits_fetch_concurrency"}}</dt>
|
||||||
<dd>{{.Repository.CommitsFetchConcurrency}}</dd>
|
<dd>{{.Repository.CommitsFetchConcurrency}}</dd>
|
||||||
|
|
||||||
|
<div class="ui divider"></div>
|
||||||
|
|
||||||
|
<dt>{{.i18n.Tr "admin.config.repo.editor.line_wrap_extensions"}}</dt>
|
||||||
|
<dd><code>{{.Repository.Editor.LineWrapExtensions}}</code></dd>
|
||||||
|
<dt>{{.i18n.Tr "admin.config.repo.editor.previewable_file_modes"}}</dt>
|
||||||
|
<dd><code>{{.Repository.Editor.PreviewableFileModes}}</code></dd>
|
||||||
|
|
||||||
|
<div class="ui divider"></div>
|
||||||
|
|
||||||
|
<dt>{{.i18n.Tr "admin.config.repo.upload.enabled"}}</dt>
|
||||||
|
<dd><i class="fa fa{{if .Repository.Upload.Enabled}}-check{{end}}-square-o"></i></dd>
|
||||||
|
<dt>{{.i18n.Tr "admin.config.repo.upload.temp_path"}}</dt>
|
||||||
|
<dd><code>{{.Repository.Upload.TempPath}}</code></dd>
|
||||||
|
<dt>{{.i18n.Tr "admin.config.repo.upload.allowed_types"}}</dt>
|
||||||
|
<dd><code>{{.Repository.Upload.AllowedTypes}}</code></dd>
|
||||||
|
<dt>{{.i18n.Tr "admin.config.repo.upload.file_max_size"}}</dt>
|
||||||
|
<dd>{{.Repository.Upload.FileMaxSize}} MB</dd>
|
||||||
|
<dt>{{.i18n.Tr "admin.config.repo.upload.max_files"}}</dt>
|
||||||
|
<dd>{{.Repository.Upload.MaxFiles}}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue