forked from kevadesu/forgejo
Merge branch 'master' into feature-activitypub
This commit is contained in:
commit
07150b33ba
1441 changed files with 45132 additions and 28797 deletions
|
@ -1,5 +1,4 @@
|
|||
//go:build sqlite
|
||||
// +build sqlite
|
||||
|
||||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
|
|
|
@ -13,17 +13,19 @@ import (
|
|||
// Federation settings
|
||||
var (
|
||||
Federation = struct {
|
||||
Enabled bool
|
||||
Algorithms []string
|
||||
DigestAlgorithm string
|
||||
GetHeaders []string
|
||||
PostHeaders []string
|
||||
Enabled bool
|
||||
ShareUserStatistics bool
|
||||
Algorithms []string
|
||||
DigestAlgorithm string
|
||||
GetHeaders []string
|
||||
PostHeaders []string
|
||||
}{
|
||||
Enabled: true,
|
||||
Algorithms: []string{"rsa-sha256", "rsa-sha512"},
|
||||
DigestAlgorithm: "SHA-256",
|
||||
GetHeaders: []string{"(request-target)", "Date"},
|
||||
PostHeaders: []string{"(request-target)", "Date", "Digest"},
|
||||
Enabled: true,
|
||||
ShareUserStatistics: true,
|
||||
Algorithms: []string{"rsa-sha256", "rsa-sha512"},
|
||||
DigestAlgorithm: "SHA-256",
|
||||
GetHeaders: []string{"(request-target)", "Date"},
|
||||
PostHeaders: []string{"(request-target)", "Date", "Digest"},
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -32,9 +32,8 @@ func GetLogDescriptions() map[string]*LogDescription {
|
|||
descs := make(map[string]*LogDescription, len(logDescriptions))
|
||||
for k, v := range logDescriptions {
|
||||
subLogDescriptions := make([]SubLogDescription, len(v.SubLogDescriptions))
|
||||
for i, s := range v.SubLogDescriptions {
|
||||
subLogDescriptions[i] = s
|
||||
}
|
||||
copy(subLogDescriptions, v.SubLogDescriptions)
|
||||
|
||||
descs[k] = &LogDescription{
|
||||
Name: v.Name,
|
||||
SubLogDescriptions: subLogDescriptions,
|
||||
|
|
46
modules/setting/packages.go
Normal file
46
modules/setting/packages.go
Normal file
|
@ -0,0 +1,46 @@
|
|||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package setting
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
)
|
||||
|
||||
// Package registry settings
|
||||
var (
|
||||
Packages = struct {
|
||||
Storage
|
||||
Enabled bool
|
||||
ChunkedUploadPath string
|
||||
RegistryHost string
|
||||
}{
|
||||
Enabled: true,
|
||||
}
|
||||
)
|
||||
|
||||
func newPackages() {
|
||||
sec := Cfg.Section("packages")
|
||||
if err := sec.MapTo(&Packages); err != nil {
|
||||
log.Fatal("Failed to map Packages settings: %v", err)
|
||||
}
|
||||
|
||||
Packages.Storage = getStorage("packages", "", nil)
|
||||
|
||||
appURL, _ := url.Parse(AppURL)
|
||||
Packages.RegistryHost = appURL.Host
|
||||
|
||||
Packages.ChunkedUploadPath = filepath.ToSlash(sec.Key("CHUNKED_UPLOAD_PATH").MustString("tmp/package-upload"))
|
||||
if !filepath.IsAbs(Packages.ChunkedUploadPath) {
|
||||
Packages.ChunkedUploadPath = filepath.ToSlash(filepath.Join(AppDataPath, Packages.ChunkedUploadPath))
|
||||
}
|
||||
|
||||
if err := os.MkdirAll(Packages.ChunkedUploadPath, os.ModePerm); err != nil {
|
||||
log.Error("Unable to create chunked upload directory: %s (%v)", Packages.ChunkedUploadPath, err)
|
||||
}
|
||||
}
|
|
@ -154,7 +154,7 @@ var (
|
|||
PrefixArchiveFiles: true,
|
||||
DisableMigrations: false,
|
||||
DisableStars: false,
|
||||
DefaultBranch: "master",
|
||||
DefaultBranch: "main",
|
||||
|
||||
// Repository editor settings
|
||||
Editor: struct {
|
||||
|
@ -295,6 +295,10 @@ func newRepository() {
|
|||
log.Fatal("Failed to map Repository.PullRequest settings: %v", err)
|
||||
}
|
||||
|
||||
if !Cfg.Section("packages").Key("ENABLED").MustBool(false) {
|
||||
Repository.DisabledRepoUnits = append(Repository.DisabledRepoUnits, "repo.packages")
|
||||
}
|
||||
|
||||
// Handle default trustmodel settings
|
||||
Repository.Signing.DefaultTrustModel = strings.ToLower(strings.TrimSpace(Repository.Signing.DefaultTrustModel))
|
||||
if Repository.Signing.DefaultTrustModel == "default" {
|
||||
|
|
|
@ -27,7 +27,6 @@ import (
|
|||
"code.gitea.io/gitea/modules/user"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
|
||||
"github.com/unknwon/com"
|
||||
gossh "golang.org/x/crypto/ssh"
|
||||
ini "gopkg.in/ini.v1"
|
||||
)
|
||||
|
@ -89,13 +88,15 @@ var (
|
|||
// AppDataPath is the default path for storing data.
|
||||
// It maps to ini:"APP_DATA_PATH" and defaults to AppWorkPath + "/data"
|
||||
AppDataPath string
|
||||
// LocalURL is the url for locally running applications to contact Gitea. It always has a '/' suffix
|
||||
// It maps to ini:"LOCAL_ROOT_URL"
|
||||
LocalURL string
|
||||
|
||||
// Server settings
|
||||
Protocol Scheme
|
||||
Domain string
|
||||
HTTPAddr string
|
||||
HTTPPort string
|
||||
LocalURL string
|
||||
RedirectOtherPort bool
|
||||
PortToRedirect string
|
||||
OfflineMode bool
|
||||
|
@ -105,6 +106,7 @@ var (
|
|||
StaticCacheTime time.Duration
|
||||
EnableGzip bool
|
||||
LandingPageURL LandingPage
|
||||
LandingPageCustom string
|
||||
UnixSocketPermission uint32
|
||||
EnablePprof bool
|
||||
PprofDataPath string
|
||||
|
@ -164,7 +166,7 @@ var (
|
|||
Domain: "",
|
||||
Port: 22,
|
||||
ServerCiphers: []string{"chacha20-poly1305@openssh.com", "aes128-ctr", "aes192-ctr", "aes256-ctr", "aes128-gcm@openssh.com", "aes256-gcm@openssh.com"},
|
||||
ServerKeyExchanges: []string{"curve25519-sha256@libssh.org", "ecdh-sha2-nistp256", "ecdh-sha2-nistp384", "ecdh-sha2-nistp521", "diffie-hellman-group14-sha1"},
|
||||
ServerKeyExchanges: []string{"curve25519-sha256", "ecdh-sha2-nistp256", "ecdh-sha2-nistp384", "ecdh-sha2-nistp521", "diffie-hellman-group14-sha256", "diffie-hellman-group14-sha1"},
|
||||
ServerMACs: []string{"hmac-sha2-256-etm@openssh.com", "hmac-sha2-256", "hmac-sha1"},
|
||||
KeygenPath: "ssh-keygen",
|
||||
MinimumKeySizeCheck: true,
|
||||
|
@ -195,6 +197,13 @@ var (
|
|||
PasswordCheckPwn bool
|
||||
SuccessfulTokensCacheSize int
|
||||
|
||||
Camo = struct {
|
||||
Enabled bool
|
||||
ServerURL string `ini:"SERVER_URL"`
|
||||
HMACKey string `ini:"HMAC_KEY"`
|
||||
Allways bool
|
||||
}{}
|
||||
|
||||
// UI settings
|
||||
UI = struct {
|
||||
ExplorePagingNum int
|
||||
|
@ -203,6 +212,7 @@ var (
|
|||
MembersPagingNum int
|
||||
FeedMaxCommitNum int
|
||||
FeedPagingNum int
|
||||
PackagesPagingNum int
|
||||
GraphMaxCommitNum int
|
||||
CodeCommentLines int
|
||||
ReactionMaxUserNum int
|
||||
|
@ -255,6 +265,7 @@ var (
|
|||
MembersPagingNum: 20,
|
||||
FeedMaxCommitNum: 5,
|
||||
FeedPagingNum: 20,
|
||||
PackagesPagingNum: 20,
|
||||
GraphMaxCommitNum: 100,
|
||||
CodeCommentLines: 4,
|
||||
ReactionMaxUserNum: 10,
|
||||
|
@ -601,7 +612,7 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
|
|||
|
||||
Cfg.NameMapper = ini.SnackCase
|
||||
|
||||
homeDir, err := com.HomeDir()
|
||||
homeDir, err := util.HomeDir()
|
||||
if err != nil {
|
||||
log.Fatal("Failed to get home directory: %v", err)
|
||||
}
|
||||
|
@ -747,6 +758,7 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
|
|||
}
|
||||
}
|
||||
LocalURL = sec.Key("LOCAL_ROOT_URL").MustString(defaultLocalURL)
|
||||
LocalURL = strings.TrimRight(LocalURL, "/") + "/"
|
||||
RedirectOtherPort = sec.Key("REDIRECT_OTHER_PORT").MustBool(false)
|
||||
PortToRedirect = sec.Key("PORT_TO_REDIRECT").MustString("80")
|
||||
OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
|
||||
|
@ -765,15 +777,19 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
|
|||
PprofDataPath = filepath.Join(AppWorkPath, PprofDataPath)
|
||||
}
|
||||
|
||||
switch sec.Key("LANDING_PAGE").MustString("home") {
|
||||
landingPage := sec.Key("LANDING_PAGE").MustString("home")
|
||||
switch landingPage {
|
||||
case "explore":
|
||||
LandingPageURL = LandingPageExplore
|
||||
case "organizations":
|
||||
LandingPageURL = LandingPageOrganizations
|
||||
case "login":
|
||||
LandingPageURL = LandingPageLogin
|
||||
default:
|
||||
case "":
|
||||
case "home":
|
||||
LandingPageURL = LandingPageHome
|
||||
default:
|
||||
LandingPageURL = LandingPage(landingPage)
|
||||
}
|
||||
|
||||
if len(SSH.Domain) == 0 {
|
||||
|
@ -1006,6 +1022,8 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
|
|||
|
||||
newPictureService()
|
||||
|
||||
newPackages()
|
||||
|
||||
if err = Cfg.Section("ui").MapTo(&UI); err != nil {
|
||||
log.Fatal("Failed to map UI settings: %v", err)
|
||||
} else if err = Cfg.Section("markdown").MapTo(&Markdown); err != nil {
|
||||
|
@ -1016,6 +1034,14 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
|
|||
log.Fatal("Failed to map API settings: %v", err)
|
||||
} else if err = Cfg.Section("metrics").MapTo(&Metrics); err != nil {
|
||||
log.Fatal("Failed to map Metrics settings: %v", err)
|
||||
} else if err = Cfg.Section("camo").MapTo(&Camo); err != nil {
|
||||
log.Fatal("Failed to map Camo settings: %v", err)
|
||||
}
|
||||
|
||||
if Camo.Enabled {
|
||||
if Camo.ServerURL == "" || Camo.HMACKey == "" {
|
||||
log.Fatal(`Camo settings require "SERVER_URL" and HMAC_KEY`)
|
||||
}
|
||||
}
|
||||
|
||||
u := *appURL
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue