mirror of
https://github.com/gogs/gogs.git
synced 2026-07-01 02:07:47 +02:00
conf: overhaul server settings (#5928)
* conf: rename package * Requires Go 1.12 * Fix lint * Fix lint * Overhaul * db: fix tests * Save my work * Fix tests * Server.UnixSocketPermission * Server.LocalRootURL * SSH settings * Server.OfflineMode * Save my work * App.Version * Remove [server] STATIC_ROOT_PATH * Server.LandingURL
This commit is contained in:
@@ -19,9 +19,9 @@ import (
|
||||
"github.com/gogs/git-module"
|
||||
api "github.com/gogs/go-gogs-client"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/lazyregexp"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
@@ -134,8 +134,8 @@ func (a *Action) ShortRepoPath() string {
|
||||
}
|
||||
|
||||
func (a *Action) GetRepoLink() string {
|
||||
if len(setting.AppSubURL) > 0 {
|
||||
return path.Join(setting.AppSubURL, a.GetRepoPath())
|
||||
if conf.Server.Subpath != "" {
|
||||
return path.Join(conf.Server.Subpath, a.GetRepoPath())
|
||||
}
|
||||
return "/" + a.GetRepoPath()
|
||||
}
|
||||
@@ -495,8 +495,8 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
||||
}
|
||||
}
|
||||
|
||||
if len(opts.Commits.Commits) > setting.UI.FeedMaxCommitNum {
|
||||
opts.Commits.Commits = opts.Commits.Commits[:setting.UI.FeedMaxCommitNum]
|
||||
if len(opts.Commits.Commits) > conf.UI.FeedMaxCommitNum {
|
||||
opts.Commits.Commits = opts.Commits.Commits[:conf.UI.FeedMaxCommitNum]
|
||||
}
|
||||
|
||||
data, err := jsoniter.Marshal(opts.Commits)
|
||||
@@ -540,7 +540,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
compareURL := setting.AppURL + opts.Commits.CompareURL
|
||||
compareURL := conf.Server.ExternalURL + opts.Commits.CompareURL
|
||||
if isNewRef {
|
||||
compareURL = ""
|
||||
if err = PrepareWebhooks(repo, HOOK_EVENT_CREATE, &api.CreatePayload{
|
||||
@@ -692,8 +692,8 @@ type MirrorSyncPushActionOptions struct {
|
||||
|
||||
// MirrorSyncPushAction adds new action for mirror synchronization of pushed commits.
|
||||
func MirrorSyncPushAction(repo *Repository, opts MirrorSyncPushActionOptions) error {
|
||||
if len(opts.Commits.Commits) > setting.UI.FeedMaxCommitNum {
|
||||
opts.Commits.Commits = opts.Commits.Commits[:setting.UI.FeedMaxCommitNum]
|
||||
if len(opts.Commits.Commits) > conf.UI.FeedMaxCommitNum {
|
||||
opts.Commits.Commits = opts.Commits.Commits[:conf.UI.FeedMaxCommitNum]
|
||||
}
|
||||
|
||||
apiCommits, err := opts.Commits.ToApiPayloadCommits(repo.RepoPath(), repo.HTMLURL())
|
||||
@@ -707,7 +707,7 @@ func MirrorSyncPushAction(repo *Repository, opts MirrorSyncPushActionOptions) er
|
||||
Ref: opts.RefName,
|
||||
Before: opts.OldCommitID,
|
||||
After: opts.NewCommitID,
|
||||
CompareURL: setting.AppURL + opts.Commits.CompareURL,
|
||||
CompareURL: conf.Server.ExternalURL + opts.Commits.CompareURL,
|
||||
Commits: apiCommits,
|
||||
Repo: repo.APIFormat(nil),
|
||||
Pusher: apiPusher,
|
||||
@@ -738,8 +738,8 @@ func MirrorSyncDeleteAction(repo *Repository, refName string) error {
|
||||
// actorID is the user who's requesting, ctxUserID is the user/org that is requested.
|
||||
// actorID can be -1 when isProfile is true or to skip the permission check.
|
||||
func GetFeeds(ctxUser *User, actorID, afterID int64, isProfile bool) ([]*Action, error) {
|
||||
actions := make([]*Action, 0, setting.UI.User.NewsFeedPagingNum)
|
||||
sess := x.Limit(setting.UI.User.NewsFeedPagingNum).Where("user_id = ?", ctxUser.ID).Desc("id")
|
||||
actions := make([]*Action, 0, conf.UI.User.NewsFeedPagingNum)
|
||||
sess := x.Limit(conf.UI.User.NewsFeedPagingNum).Where("user_id = ?", ctxUser.ID).Desc("id")
|
||||
if afterID > 0 {
|
||||
sess.And("id < ?", afterID)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
gouuid "github.com/satori/go.uuid"
|
||||
"xorm.io/xorm"
|
||||
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
)
|
||||
|
||||
// Attachment represent a attachment of issue/comment/release.
|
||||
@@ -44,7 +44,7 @@ func (a *Attachment) AfterSet(colName string, _ xorm.Cell) {
|
||||
|
||||
// AttachmentLocalPath returns where attachment is stored in local file system based on given UUID.
|
||||
func AttachmentLocalPath(uuid string) string {
|
||||
return path.Join(setting.AttachmentPath, uuid[0:1], uuid[1:2], uuid)
|
||||
return path.Join(conf.AttachmentPath, uuid[0:1], uuid[1:2], uuid)
|
||||
}
|
||||
|
||||
// LocalPath returns where attachment is stored in local file system.
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
|
||||
"github.com/gogs/git-module"
|
||||
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/template/highlight"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
@@ -69,7 +69,7 @@ func init() {
|
||||
|
||||
// ComputedInlineDiffFor computes inline diff for the given line.
|
||||
func (diffSection *DiffSection) ComputedInlineDiffFor(diffLine *git.DiffLine) template.HTML {
|
||||
if setting.Git.DisableDiffHighlight {
|
||||
if conf.Git.DisableDiffHighlight {
|
||||
return template.HTML(html.EscapeString(diffLine.Content[1:]))
|
||||
}
|
||||
var (
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
api "github.com/gogs/go-gogs-client"
|
||||
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
@@ -969,9 +969,9 @@ func Issues(opts *IssuesOptions) ([]*Issue, error) {
|
||||
return make([]*Issue, 0), nil
|
||||
}
|
||||
|
||||
sess.Limit(setting.UI.IssuePagingNum, (opts.Page-1)*setting.UI.IssuePagingNum)
|
||||
sess.Limit(conf.UI.IssuePagingNum, (opts.Page-1)*conf.UI.IssuePagingNum)
|
||||
|
||||
issues := make([]*Issue, 0, setting.UI.IssuePagingNum)
|
||||
issues := make([]*Issue, 0, conf.UI.IssuePagingNum)
|
||||
if err := sess.Find(&issues); err != nil {
|
||||
return nil, fmt.Errorf("Find: %v", err)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
"gogs.io/gogs/internal/mailer"
|
||||
"gogs.io/gogs/internal/markup"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
)
|
||||
|
||||
func (issue *Issue) MailSubject() string {
|
||||
@@ -95,7 +95,7 @@ func NewMailerIssue(issue *Issue) mailer.Issue {
|
||||
// 1. Repository watchers, users who participated in comments and the assignee.
|
||||
// 2. Users who are not in 1. but get mentioned in current issue/comment.
|
||||
func mailIssueCommentToParticipants(issue *Issue, doer *User, mentions []string) error {
|
||||
if !setting.Service.EnableNotifyMail {
|
||||
if !conf.Service.EnableNotifyMail {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"net/smtp"
|
||||
"net/textproto"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -27,8 +27,8 @@ import (
|
||||
"gogs.io/gogs/internal/auth/github"
|
||||
"gogs.io/gogs/internal/auth/ldap"
|
||||
"gogs.io/gogs/internal/auth/pam"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
type LoginType int
|
||||
@@ -462,7 +462,7 @@ var localLoginSources = &LocalLoginSources{}
|
||||
// LoadAuthSources loads authentication sources from local files
|
||||
// and converts them into login sources.
|
||||
func LoadAuthSources() {
|
||||
authdPath := path.Join(setting.CustomPath, "conf/auth.d")
|
||||
authdPath := filepath.Join(conf.CustomDir(), "conf", "auth.d")
|
||||
if !com.IsDir(authdPath) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
log "unknwon.dev/clog/v2"
|
||||
"xorm.io/xorm"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/osutil"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
func generateAndMigrateGitHooks(x *xorm.Engine) (err error) {
|
||||
@@ -32,18 +32,18 @@ func generateAndMigrateGitHooks(x *xorm.Engine) (err error) {
|
||||
var (
|
||||
hookNames = []string{"pre-receive", "update", "post-receive"}
|
||||
hookTpls = []string{
|
||||
fmt.Sprintf("#!/usr/bin/env %s\n\"%s\" hook --config='%s' pre-receive\n", setting.ScriptType, setting.AppPath, setting.CustomConf),
|
||||
fmt.Sprintf("#!/usr/bin/env %s\n\"%s\" hook --config='%s' update $1 $2 $3\n", setting.ScriptType, setting.AppPath, setting.CustomConf),
|
||||
fmt.Sprintf("#!/usr/bin/env %s\n\"%s\" hook --config='%s' post-receive\n", setting.ScriptType, setting.AppPath, setting.CustomConf),
|
||||
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' update $1 $2 $3\n", conf.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),
|
||||
}
|
||||
)
|
||||
|
||||
// Cleanup old update.log and http.log files.
|
||||
filepath.Walk(setting.LogRootPath, func(path string, info os.FileInfo, err error) error {
|
||||
_ = filepath.Walk(conf.LogRootPath, func(path string, info os.FileInfo, err error) error {
|
||||
if !info.IsDir() &&
|
||||
(strings.HasPrefix(filepath.Base(path), "update.log") ||
|
||||
strings.HasPrefix(filepath.Base(path), "http.log")) {
|
||||
os.Remove(path)
|
||||
_ = os.Remove(path)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
@@ -63,7 +63,7 @@ func generateAndMigrateGitHooks(x *xorm.Engine) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
repoBase := filepath.Join(setting.RepoRootPath, strings.ToLower(user.Name), strings.ToLower(repo.Name))
|
||||
repoBase := filepath.Join(conf.RepoRootPath, strings.ToLower(user.Name), strings.ToLower(repo.Name))
|
||||
repoPath := repoBase + ".git"
|
||||
wikiPath := repoBase + ".wiki.git"
|
||||
log.Trace("[%04d]: %s", idx, repoPath)
|
||||
@@ -82,7 +82,7 @@ func generateAndMigrateGitHooks(x *xorm.Engine) (err error) {
|
||||
// In case user runs this migration multiple times, and custom hook exists,
|
||||
// we assume it's been migrated already.
|
||||
if hookName != "update" && osutil.IsFile(oldHookPath) && !com.IsExist(customHookDir) {
|
||||
os.MkdirAll(customHookDir, os.ModePerm)
|
||||
_ = os.MkdirAll(customHookDir, os.ModePerm)
|
||||
if err = os.Rename(oldHookPath, newHookPath); err != nil {
|
||||
return fmt.Errorf("move hook file to custom directory '%s' -> '%s': %v", oldHookPath, newHookPath, err)
|
||||
}
|
||||
@@ -93,7 +93,7 @@ func generateAndMigrateGitHooks(x *xorm.Engine) (err error) {
|
||||
}
|
||||
|
||||
if com.IsDir(wikiPath) {
|
||||
os.MkdirAll(wikiHookDir, os.ModePerm)
|
||||
_ = os.MkdirAll(wikiHookDir, os.ModePerm)
|
||||
wikiHookPath := filepath.Join(wikiHookDir, hookName)
|
||||
if err = ioutil.WriteFile(wikiHookPath, []byte(hookTpls[i]), os.ModePerm); err != nil {
|
||||
return fmt.Errorf("write wiki hook file '%s': %v", wikiHookPath, err)
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
"github.com/gogs/git-module"
|
||||
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
)
|
||||
|
||||
func updateRepositorySizes(x *xorm.Engine) (err error) {
|
||||
@@ -60,7 +60,7 @@ func updateRepositorySizes(x *xorm.Engine) (err error) {
|
||||
continue
|
||||
}
|
||||
|
||||
repoPath := filepath.Join(setting.RepoRootPath, strings.ToLower(user.Name), strings.ToLower(repo.Name)) + ".git"
|
||||
repoPath := filepath.Join(conf.RepoRootPath, strings.ToLower(user.Name), strings.ToLower(repo.Name)) + ".git"
|
||||
countObject, err := git.GetRepoSize(repoPath)
|
||||
if err != nil {
|
||||
log.Warn("GetRepoSize: %v", err)
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
"xorm.io/xorm"
|
||||
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
)
|
||||
|
||||
func updateRepositoryDescriptionField(x *xorm.Engine) error {
|
||||
@@ -20,13 +20,13 @@ func updateRepositoryDescriptionField(x *xorm.Engine) error {
|
||||
return nil
|
||||
}
|
||||
switch {
|
||||
case setting.UseMySQL:
|
||||
case conf.UseMySQL:
|
||||
_, err = x.Exec("ALTER TABLE `repository` MODIFY `description` VARCHAR(512);")
|
||||
case setting.UseMSSQL:
|
||||
case conf.UseMSSQL:
|
||||
_, err = x.Exec("ALTER TABLE `repository` ALTER COLUMN `description` VARCHAR(512);")
|
||||
case setting.UsePostgreSQL:
|
||||
case conf.UsePostgreSQL:
|
||||
_, err = x.Exec("ALTER TABLE `repository` ALTER COLUMN `description` TYPE VARCHAR(512);")
|
||||
case setting.UseSQLite3:
|
||||
case conf.UseSQLite3:
|
||||
// Sqlite3 uses TEXT type by default for any string type field.
|
||||
// Keep this comment to mention that we don't missed any option.
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
|
||||
api "github.com/gogs/go-gogs-client"
|
||||
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
)
|
||||
|
||||
// Milestone represents a milestone of repository.
|
||||
@@ -157,10 +157,10 @@ func GetMilestonesByRepoID(repoID int64) ([]*Milestone, error) {
|
||||
|
||||
// GetMilestones returns a list of milestones of given repository and status.
|
||||
func GetMilestones(repoID int64, page int, isClosed bool) ([]*Milestone, error) {
|
||||
miles := make([]*Milestone, 0, setting.UI.IssuePagingNum)
|
||||
miles := make([]*Milestone, 0, conf.UI.IssuePagingNum)
|
||||
sess := x.Where("repo_id = ? AND is_closed = ?", repoID, isClosed)
|
||||
if page > 0 {
|
||||
sess = sess.Limit(setting.UI.IssuePagingNum, (page-1)*setting.UI.IssuePagingNum)
|
||||
sess = sess.Limit(conf.UI.IssuePagingNum, (page-1)*conf.UI.IssuePagingNum)
|
||||
}
|
||||
return miles, sess.Find(&miles)
|
||||
}
|
||||
|
||||
@@ -20,11 +20,11 @@ import (
|
||||
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/process"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/sync"
|
||||
)
|
||||
|
||||
var MirrorQueue = sync.NewUniqueQueue(setting.Repository.MirrorQueueLength)
|
||||
var MirrorQueue = sync.NewUniqueQueue(conf.Repository.MirrorQueueLength)
|
||||
|
||||
// Mirror represents mirror information of a repository.
|
||||
type Mirror struct {
|
||||
@@ -258,7 +258,7 @@ func parseRemoteUpdateOutput(output string) []*mirrorSyncResult {
|
||||
func (m *Mirror) runSync() ([]*mirrorSyncResult, bool) {
|
||||
repoPath := m.Repo.RepoPath()
|
||||
wikiPath := m.Repo.WikiPath()
|
||||
timeout := time.Duration(setting.Git.Timeout.Mirror) * time.Second
|
||||
timeout := time.Duration(conf.Git.Timeout.Mirror) * time.Second
|
||||
|
||||
// Do a fast-fail testing against on repository URL to ensure it is accessible under
|
||||
// good condition to prevent long blocking on URL resolution without syncing anything.
|
||||
|
||||
@@ -24,8 +24,8 @@ import (
|
||||
"xorm.io/core"
|
||||
"xorm.io/xorm"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/db/migrations"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
// Engine represents a XORM engine or session.
|
||||
@@ -75,17 +75,17 @@ func init() {
|
||||
}
|
||||
|
||||
func LoadConfigs() {
|
||||
sec := setting.Cfg.Section("database")
|
||||
sec := conf.File.Section("database")
|
||||
DbCfg.Type = sec.Key("DB_TYPE").String()
|
||||
switch DbCfg.Type {
|
||||
case "sqlite3":
|
||||
setting.UseSQLite3 = true
|
||||
conf.UseSQLite3 = true
|
||||
case "mysql":
|
||||
setting.UseMySQL = true
|
||||
conf.UseMySQL = true
|
||||
case "postgres":
|
||||
setting.UsePostgreSQL = true
|
||||
conf.UsePostgreSQL = true
|
||||
case "mssql":
|
||||
setting.UseMSSQL = true
|
||||
conf.UseMSSQL = true
|
||||
}
|
||||
DbCfg.Host = sec.Key("HOST").String()
|
||||
DbCfg.Name = sec.Key("NAME").String()
|
||||
@@ -189,8 +189,8 @@ func SetEngine() (err error) {
|
||||
|
||||
// WARNING: for serv command, MUST remove the output to os.stdout,
|
||||
// so use log file to instead print to stdout.
|
||||
sec := setting.Cfg.Section("log.xorm")
|
||||
logger, err := log.NewFileWriter(path.Join(setting.LogRootPath, "xorm.log"),
|
||||
sec := conf.File.Section("log.xorm")
|
||||
logger, err := log.NewFileWriter(path.Join(conf.LogRootPath, "xorm.log"),
|
||||
log.FileRotationConfig{
|
||||
Rotate: sec.Key("ROTATE").MustBool(true),
|
||||
Daily: sec.Key("ROTATE_DAILY").MustBool(true),
|
||||
@@ -206,7 +206,7 @@ func SetEngine() (err error) {
|
||||
x.SetMaxIdleConns(0)
|
||||
x.SetConnMaxLifetime(time.Second)
|
||||
|
||||
if setting.ProdMode {
|
||||
if conf.IsProdMode() {
|
||||
x.SetLogger(xorm.NewSimpleLogger3(logger, xorm.DEFAULT_LOG_PREFIX, xorm.DEFAULT_LOG_FLAG, core.LOG_WARNING))
|
||||
} else {
|
||||
x.SetLogger(xorm.NewSimpleLogger(logger))
|
||||
@@ -389,7 +389,7 @@ func ImportDatabase(dirPath string, verbose bool) (err error) {
|
||||
}
|
||||
|
||||
// PostgreSQL needs manually reset table sequence for auto increment keys
|
||||
if setting.UsePostgreSQL {
|
||||
if conf.UsePostgreSQL {
|
||||
rawTableName := snakeMapper.Obj2Table(tableName)
|
||||
seqName := rawTableName + "_id_seq"
|
||||
if _, err = x.Exec(fmt.Sprintf(`SELECT setval('%s', COALESCE((SELECT MAX(id)+1 FROM "%s"), 1), false);`, seqName, rawTableName)); err != nil {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -18,14 +19,14 @@ import (
|
||||
"github.com/gogs/git-module"
|
||||
api "github.com/gogs/go-gogs-client"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/osutil"
|
||||
"gogs.io/gogs/internal/process"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/sync"
|
||||
)
|
||||
|
||||
var PullRequestQueue = sync.NewUniqueQueue(setting.Repository.PullRequestQueueLength)
|
||||
var PullRequestQueue = sync.NewUniqueQueue(conf.Repository.PullRequestQueueLength)
|
||||
|
||||
type PullRequestType int
|
||||
|
||||
@@ -218,9 +219,9 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
|
||||
|
||||
// Create temporary directory to store temporary copy of the base repository,
|
||||
// and clean it up when operation finished regardless of succeed or not.
|
||||
tmpBasePath := path.Join(setting.AppDataPath, "tmp/repos", com.ToStr(time.Now().Nanosecond())+".git")
|
||||
os.MkdirAll(path.Dir(tmpBasePath), os.ModePerm)
|
||||
defer os.RemoveAll(path.Dir(tmpBasePath))
|
||||
tmpBasePath := filepath.Join(conf.Server.AppDataPath, "tmp", "repos", com.ToStr(time.Now().Nanosecond())+".git")
|
||||
os.MkdirAll(filepath.Dir(tmpBasePath), os.ModePerm)
|
||||
defer os.RemoveAll(filepath.Dir(tmpBasePath))
|
||||
|
||||
// Clone the base repository to the defined temporary directory,
|
||||
// and checks out to base branch directly.
|
||||
@@ -378,7 +379,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
|
||||
Ref: git.BRANCH_PREFIX + pr.BaseBranch,
|
||||
Before: pr.MergeBase,
|
||||
After: mergeCommit.ID.String(),
|
||||
CompareURL: setting.AppURL + pr.BaseRepo.ComposeCompareURL(pr.MergeBase, pr.MergedCommitID),
|
||||
CompareURL: conf.Server.ExternalURL + pr.BaseRepo.ComposeCompareURL(pr.MergeBase, pr.MergedCommitID),
|
||||
Commits: commits,
|
||||
Repo: pr.BaseRepo.APIFormat(nil),
|
||||
Pusher: pr.HeadRepo.MustOwner().APIFormat(),
|
||||
|
||||
@@ -30,13 +30,12 @@ import (
|
||||
"github.com/gogs/git-module"
|
||||
api "github.com/gogs/go-gogs-client"
|
||||
|
||||
"gogs.io/gogs/internal/assets/conf"
|
||||
"gogs.io/gogs/internal/avatar"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/markup"
|
||||
"gogs.io/gogs/internal/osutil"
|
||||
"gogs.io/gogs/internal/process"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/sync"
|
||||
)
|
||||
|
||||
@@ -61,7 +60,7 @@ func LoadRepoConfig() {
|
||||
if err != nil {
|
||||
log.Fatal("Failed to get %s files: %v", t, err)
|
||||
}
|
||||
customPath := path.Join(setting.CustomPath, "conf", t)
|
||||
customPath := filepath.Join(conf.CustomDir(), "conf", t)
|
||||
if com.IsDir(customPath) {
|
||||
customFiles, err := com.StatDir(customPath)
|
||||
if err != nil {
|
||||
@@ -88,13 +87,13 @@ func LoadRepoConfig() {
|
||||
|
||||
// Filter out invalid names and promote preferred licenses.
|
||||
sortedLicenses := make([]string, 0, len(Licenses))
|
||||
for _, name := range setting.Repository.PreferredLicenses {
|
||||
for _, name := range conf.Repository.PreferredLicenses {
|
||||
if com.IsSliceContainsStr(Licenses, name) {
|
||||
sortedLicenses = append(sortedLicenses, name)
|
||||
}
|
||||
}
|
||||
for _, name := range Licenses {
|
||||
if !com.IsSliceContainsStr(setting.Repository.PreferredLicenses, name) {
|
||||
if !com.IsSliceContainsStr(conf.Repository.PreferredLicenses, name) {
|
||||
sortedLicenses = append(sortedLicenses, name)
|
||||
}
|
||||
}
|
||||
@@ -111,18 +110,18 @@ func NewRepoContext() {
|
||||
|
||||
// Check Git version.
|
||||
var err error
|
||||
setting.Git.Version, err = git.BinVersion()
|
||||
conf.Git.Version, err = git.BinVersion()
|
||||
if err != nil {
|
||||
log.Fatal("Failed to get Git version: %v", err)
|
||||
}
|
||||
|
||||
log.Trace("Git version: %s", setting.Git.Version)
|
||||
if version.Compare("1.8.3", setting.Git.Version, ">") {
|
||||
log.Trace("Git version: %s", conf.Git.Version)
|
||||
if version.Compare("1.8.3", conf.Git.Version, ">") {
|
||||
log.Fatal("Gogs requires Git version greater or equal to 1.8.3")
|
||||
}
|
||||
git.HookDir = "custom_hooks"
|
||||
git.HookSampleDir = "hooks"
|
||||
git.DefaultCommitsPageSize = setting.UI.User.CommitsPagingNum
|
||||
git.DefaultCommitsPageSize = conf.UI.User.CommitsPagingNum
|
||||
|
||||
// Git requires setting user.name and user.email in order to commit changes.
|
||||
for configKey, defaultValue := range map[string]string{"user.name": "Gogs", "user.email": "gogs@fake.local"} {
|
||||
@@ -145,7 +144,7 @@ func NewRepoContext() {
|
||||
log.Fatal("Failed to execute 'git config --global core.quotepath false': %v - %s", err, stderr)
|
||||
}
|
||||
|
||||
RemoveAllWithNotice("Clean up repository temporary data", filepath.Join(setting.AppDataPath, "tmp"))
|
||||
RemoveAllWithNotice("Clean up repository temporary data", filepath.Join(conf.Server.AppDataPath, "tmp"))
|
||||
}
|
||||
|
||||
// Repository contains information of a repository.
|
||||
@@ -292,12 +291,12 @@ func (repo *Repository) FullName() string {
|
||||
}
|
||||
|
||||
func (repo *Repository) HTMLURL() string {
|
||||
return setting.AppURL + repo.FullName()
|
||||
return conf.Server.ExternalURL + repo.FullName()
|
||||
}
|
||||
|
||||
// CustomAvatarPath returns repository custom avatar file path.
|
||||
func (repo *Repository) CustomAvatarPath() string {
|
||||
return filepath.Join(setting.RepositoryAvatarUploadPath, com.ToStr(repo.ID))
|
||||
return filepath.Join(conf.RepositoryAvatarUploadPath, com.ToStr(repo.ID))
|
||||
}
|
||||
|
||||
// RelAvatarLink returns relative avatar link to the site domain,
|
||||
@@ -308,14 +307,14 @@ func (repo *Repository) RelAvatarLink() string {
|
||||
if !com.IsExist(repo.CustomAvatarPath()) {
|
||||
return defaultImgUrl
|
||||
}
|
||||
return fmt.Sprintf("%s/%s/%d", setting.AppSubURL, REPO_AVATAR_URL_PREFIX, repo.ID)
|
||||
return fmt.Sprintf("%s/%s/%d", conf.Server.Subpath, REPO_AVATAR_URL_PREFIX, repo.ID)
|
||||
}
|
||||
|
||||
// AvatarLink returns repository avatar absolute link.
|
||||
func (repo *Repository) AvatarLink() string {
|
||||
link := repo.RelAvatarLink()
|
||||
if link[0] == '/' && link[1] != '/' {
|
||||
return setting.AppURL + strings.TrimPrefix(link, setting.AppSubURL)[1:]
|
||||
return conf.Server.ExternalURL + strings.TrimPrefix(link, conf.Server.Subpath)[1:]
|
||||
}
|
||||
return link
|
||||
}
|
||||
@@ -328,7 +327,7 @@ func (repo *Repository) UploadAvatar(data []byte) error {
|
||||
return fmt.Errorf("decode image: %v", err)
|
||||
}
|
||||
|
||||
os.MkdirAll(setting.RepositoryAvatarUploadPath, os.ModePerm)
|
||||
_ = os.MkdirAll(conf.RepositoryAvatarUploadPath, os.ModePerm)
|
||||
fw, err := os.Create(repo.CustomAvatarPath())
|
||||
if err != nil {
|
||||
return fmt.Errorf("create custom avatar directory: %v", err)
|
||||
@@ -546,7 +545,7 @@ func (repo *Repository) RelLink() string {
|
||||
}
|
||||
|
||||
func (repo *Repository) Link() string {
|
||||
return setting.AppSubURL + "/" + repo.FullName()
|
||||
return conf.Server.Subpath + "/" + repo.FullName()
|
||||
}
|
||||
|
||||
func (repo *Repository) ComposeCompareURL(oldCommitID, newCommitID string) string {
|
||||
@@ -593,7 +592,7 @@ func (repo *Repository) NextIssueIndex() int64 {
|
||||
}
|
||||
|
||||
func (repo *Repository) LocalCopyPath() string {
|
||||
return path.Join(setting.AppDataPath, "tmp/local-repo", com.ToStr(repo.ID))
|
||||
return filepath.Join(conf.Server.AppDataPath, "tmp", "local-repo", com.ToStr(repo.ID))
|
||||
}
|
||||
|
||||
// UpdateLocalCopy fetches latest changes of given branch from repoPath to localPath.
|
||||
@@ -609,7 +608,7 @@ func UpdateLocalCopyBranch(repoPath, localPath, branch string, isWiki bool) (err
|
||||
branch = ""
|
||||
}
|
||||
if err = git.Clone(repoPath, localPath, git.CloneRepoOptions{
|
||||
Timeout: time.Duration(setting.Git.Timeout.Clone) * time.Second,
|
||||
Timeout: time.Duration(conf.Git.Timeout.Clone) * time.Second,
|
||||
Branch: branch,
|
||||
}); err != nil {
|
||||
return fmt.Errorf("git clone %s: %v", branch, err)
|
||||
@@ -685,7 +684,7 @@ type CloneLink struct {
|
||||
|
||||
// ComposeHTTPSCloneURL returns HTTPS clone URL based on given owner and repository name.
|
||||
func ComposeHTTPSCloneURL(owner, repo string) string {
|
||||
return fmt.Sprintf("%s%s/%s.git", setting.AppURL, owner, repo)
|
||||
return fmt.Sprintf("%s%s/%s.git", conf.Server.ExternalURL, owner, repo)
|
||||
}
|
||||
|
||||
func (repo *Repository) cloneLink(isWiki bool) *CloneLink {
|
||||
@@ -696,10 +695,10 @@ func (repo *Repository) cloneLink(isWiki bool) *CloneLink {
|
||||
|
||||
repo.Owner = repo.MustOwner()
|
||||
cl := new(CloneLink)
|
||||
if setting.SSH.Port != 22 {
|
||||
cl.SSH = fmt.Sprintf("ssh://%s@%s:%d/%s/%s.git", setting.RunUser, setting.SSH.Domain, setting.SSH.Port, repo.Owner.Name, repoName)
|
||||
if conf.SSH.Port != 22 {
|
||||
cl.SSH = fmt.Sprintf("ssh://%s@%s:%d/%s/%s.git", conf.App.RunUser, conf.SSH.Domain, conf.SSH.Port, repo.Owner.Name, repoName)
|
||||
} else {
|
||||
cl.SSH = fmt.Sprintf("%s@%s:%s/%s.git", setting.RunUser, setting.SSH.Domain, repo.Owner.Name, repoName)
|
||||
cl.SSH = fmt.Sprintf("%s@%s:%s/%s.git", conf.App.RunUser, conf.SSH.Domain, repo.Owner.Name, repoName)
|
||||
}
|
||||
cl.HTTPS = ComposeHTTPSCloneURL(repo.Owner.Name, repoName)
|
||||
return cl
|
||||
@@ -764,7 +763,7 @@ func MigrateRepository(doer, owner *User, opts MigrateRepoOptions) (*Repository,
|
||||
repo.NumWatches = 1
|
||||
}
|
||||
|
||||
migrateTimeout := time.Duration(setting.Git.Timeout.Migrate) * time.Second
|
||||
migrateTimeout := time.Duration(conf.Git.Timeout.Migrate) * time.Second
|
||||
|
||||
RemoveAllWithNotice("Repository path erase before creation", repoPath)
|
||||
if err = git.Clone(opts.RemoteAddr, repoPath, git.CloneRepoOptions{
|
||||
@@ -820,9 +819,9 @@ func MigrateRepository(doer, owner *User, opts MigrateRepoOptions) (*Repository,
|
||||
if opts.IsMirror {
|
||||
if _, err = x.InsertOne(&Mirror{
|
||||
RepoID: repo.ID,
|
||||
Interval: setting.Mirror.DefaultInterval,
|
||||
Interval: conf.Mirror.DefaultInterval,
|
||||
EnablePrune: true,
|
||||
NextSync: time.Now().Add(time.Duration(setting.Mirror.DefaultInterval) * time.Hour),
|
||||
NextSync: time.Now().Add(time.Duration(conf.Mirror.DefaultInterval) * time.Hour),
|
||||
}); err != nil {
|
||||
return repo, fmt.Errorf("InsertOne: %v", err)
|
||||
}
|
||||
@@ -858,7 +857,7 @@ func createDelegateHooks(repoPath string) (err error) {
|
||||
for _, name := range git.HookNames {
|
||||
hookPath := filepath.Join(repoPath, "hooks", name)
|
||||
if err = ioutil.WriteFile(hookPath,
|
||||
[]byte(fmt.Sprintf(hooksTpls[name], setting.ScriptType, setting.AppPath, setting.CustomConf)),
|
||||
[]byte(fmt.Sprintf(hooksTpls[name], conf.ScriptType, conf.AppPath(), conf.CustomConf)),
|
||||
os.ModePerm); err != nil {
|
||||
return fmt.Errorf("create delegate hook '%s': %v", hookPath, err)
|
||||
}
|
||||
@@ -929,7 +928,7 @@ func getRepoInitFile(tp, name string) ([]byte, error) {
|
||||
relPath := path.Join("conf", tp, strings.TrimLeft(path.Clean("/"+name), "/"))
|
||||
|
||||
// Use custom file when available.
|
||||
customPath := path.Join(setting.CustomPath, relPath)
|
||||
customPath := filepath.Join(conf.CustomDir(), relPath)
|
||||
if osutil.IsFile(customPath) {
|
||||
return ioutil.ReadFile(customPath)
|
||||
}
|
||||
@@ -1768,7 +1767,7 @@ func DeleteOldRepositoryArchives() {
|
||||
log.Trace("Doing: DeleteOldRepositoryArchives")
|
||||
|
||||
formats := []string{"zip", "targz"}
|
||||
oldestTime := time.Now().Add(-setting.Cron.RepoArchiveCleanup.OlderThan)
|
||||
oldestTime := time.Now().Add(-conf.Cron.RepoArchiveCleanup.OlderThan)
|
||||
if err := x.Where("id > 0").Iterate(new(Repository),
|
||||
func(idx int, bean interface{}) error {
|
||||
repo := bean.(*Repository)
|
||||
@@ -1931,7 +1930,7 @@ func GitFsck() {
|
||||
func(idx int, bean interface{}) error {
|
||||
repo := bean.(*Repository)
|
||||
repoPath := repo.RepoPath()
|
||||
if err := git.Fsck(repoPath, setting.Cron.RepoHealthCheck.Timeout, setting.Cron.RepoHealthCheck.Args...); err != nil {
|
||||
if err := git.Fsck(repoPath, conf.Cron.RepoHealthCheck.Timeout, conf.Cron.RepoHealthCheck.Args...); err != nil {
|
||||
desc := fmt.Sprintf("Failed to perform health check on repository '%s': %v", repoPath, err)
|
||||
log.Warn(desc)
|
||||
if err = CreateRepositoryNotice(desc); err != nil {
|
||||
@@ -1945,7 +1944,7 @@ func GitFsck() {
|
||||
}
|
||||
|
||||
func GitGcRepos() error {
|
||||
args := append([]string{"gc"}, setting.Git.GCArgs...)
|
||||
args := append([]string{"gc"}, conf.Git.GCArgs...)
|
||||
return x.Where("id > 0").Iterate(new(Repository),
|
||||
func(idx int, bean interface{}) error {
|
||||
repo := bean.(*Repository)
|
||||
@@ -1953,7 +1952,7 @@ func GitGcRepos() error {
|
||||
return err
|
||||
}
|
||||
_, stderr, err := process.ExecDir(
|
||||
time.Duration(setting.Git.Timeout.GC)*time.Second,
|
||||
time.Duration(conf.Git.Timeout.GC)*time.Second,
|
||||
RepoPath(repo.Owner.Name, repo.Name), "Repository garbage collection",
|
||||
"git", args...)
|
||||
if err != nil {
|
||||
@@ -2235,7 +2234,7 @@ func GetWatchers(repoID int64) ([]*Watch, error) {
|
||||
func (repo *Repository) GetWatchers(page int) ([]*User, error) {
|
||||
users := make([]*User, 0, ItemsPerPage)
|
||||
sess := x.Limit(ItemsPerPage, (page-1)*ItemsPerPage).Where("watch.repo_id=?", repo.ID)
|
||||
if setting.UsePostgreSQL {
|
||||
if conf.UsePostgreSQL {
|
||||
sess = sess.Join("LEFT", "watch", `"user".id=watch.user_id`)
|
||||
} else {
|
||||
sess = sess.Join("LEFT", "watch", "user.id=watch.user_id")
|
||||
@@ -2326,7 +2325,7 @@ func IsStaring(userID, repoID int64) bool {
|
||||
func (repo *Repository) GetStargazers(page int) ([]*User, error) {
|
||||
users := make([]*User, 0, ItemsPerPage)
|
||||
sess := x.Limit(ItemsPerPage, (page-1)*ItemsPerPage).Where("star.repo_id=?", repo.ID)
|
||||
if setting.UsePostgreSQL {
|
||||
if conf.UsePostgreSQL {
|
||||
sess = sess.Join("LEFT", "star", `"user".id=star.uid`)
|
||||
} else {
|
||||
sess = sess.Join("LEFT", "star", "user.id=star.uid")
|
||||
|
||||
@@ -24,7 +24,7 @@ import (
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/osutil"
|
||||
"gogs.io/gogs/internal/process"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
@@ -95,7 +95,7 @@ func (repo *Repository) DiscardLocalRepoBranchChanges(branch string) error {
|
||||
// checkoutNewBranch checks out to a new branch from the a branch name.
|
||||
func checkoutNewBranch(repoPath, localPath, oldBranch, newBranch string) error {
|
||||
if err := git.Checkout(localPath, git.CheckoutOptions{
|
||||
Timeout: time.Duration(setting.Git.Timeout.Pull) * time.Second,
|
||||
Timeout: time.Duration(conf.Git.Timeout.Pull) * time.Second,
|
||||
Branch: newBranch,
|
||||
OldBranch: oldBranch,
|
||||
}); err != nil {
|
||||
@@ -231,7 +231,7 @@ func (repo *Repository) GetDiffPreview(branch, treePath, content string) (diff *
|
||||
pid := process.Add(fmt.Sprintf("GetDiffPreview [repo_path: %s]", repo.RepoPath()), cmd)
|
||||
defer process.Remove(pid)
|
||||
|
||||
diff, err = ParsePatch(setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, stdout)
|
||||
diff, err = ParsePatch(conf.Git.MaxGitDiffLines, conf.Git.MaxGitDiffLineCharacters, conf.Git.MaxGitDiffFiles, stdout)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parse path: %v", err)
|
||||
}
|
||||
@@ -318,7 +318,7 @@ type Upload struct {
|
||||
|
||||
// UploadLocalPath returns where uploads is stored in local file system based on given UUID.
|
||||
func UploadLocalPath(uuid string) string {
|
||||
return path.Join(setting.Repository.Upload.TempPath, uuid[0:1], uuid[1:2], uuid)
|
||||
return path.Join(conf.Repository.Upload.TempPath, uuid[0:1], uuid[1:2], uuid)
|
||||
}
|
||||
|
||||
// LocalPath returns where uploads are temporarily stored in local file system.
|
||||
|
||||
@@ -23,8 +23,8 @@ import (
|
||||
log "unknwon.dev/clog/v2"
|
||||
"xorm.io/xorm"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/process"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -84,7 +84,7 @@ func (k *PublicKey) OmitEmail() string {
|
||||
|
||||
// AuthorizedString returns formatted public key string for authorized_keys file.
|
||||
func (k *PublicKey) AuthorizedString() string {
|
||||
return fmt.Sprintf(_TPL_PUBLICK_KEY, setting.AppPath, k.ID, setting.CustomConf, k.Content)
|
||||
return fmt.Sprintf(_TPL_PUBLICK_KEY, conf.AppPath(), k.ID, conf.CustomConf, k.Content)
|
||||
}
|
||||
|
||||
// IsDeployKey returns true if the public key is used as deploy key.
|
||||
@@ -179,7 +179,7 @@ func parseKeyString(content string) (string, error) {
|
||||
// writeTmpKeyFile writes key content to a temporary file
|
||||
// and returns the name of that file, along with any possible errors.
|
||||
func writeTmpKeyFile(content string) (string, error) {
|
||||
tmpFile, err := ioutil.TempFile(setting.SSH.KeyTestPath, "gogs_keytest")
|
||||
tmpFile, err := ioutil.TempFile(conf.SSH.KeyTestPath, "gogs_keytest")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("TempFile: %v", err)
|
||||
}
|
||||
@@ -199,7 +199,7 @@ func SSHKeyGenParsePublicKey(key string) (string, int, error) {
|
||||
}
|
||||
defer os.Remove(tmpName)
|
||||
|
||||
stdout, stderr, err := process.Exec("SSHKeyGenParsePublicKey", setting.SSH.KeygenPath, "-lf", tmpName)
|
||||
stdout, stderr, err := process.Exec("SSHKeyGenParsePublicKey", conf.SSH.KeygenPath, "-lf", tmpName)
|
||||
if err != nil {
|
||||
return "", 0, fmt.Errorf("fail to parse public key: %s - %s", err, stderr)
|
||||
}
|
||||
@@ -274,7 +274,7 @@ func SSHNativeParsePublicKey(keyLine string) (string, int, error) {
|
||||
// CheckPublicKeyString checks if the given public key string is recognized by SSH.
|
||||
// It returns the actual public key line on success.
|
||||
func CheckPublicKeyString(content string) (_ string, err error) {
|
||||
if setting.SSH.Disabled {
|
||||
if conf.SSH.Disabled {
|
||||
return "", errors.New("SSH is disabled")
|
||||
}
|
||||
|
||||
@@ -291,7 +291,7 @@ func CheckPublicKeyString(content string) (_ string, err error) {
|
||||
// Remove any unnecessary whitespace
|
||||
content = strings.TrimSpace(content)
|
||||
|
||||
if !setting.SSH.MinimumKeySizeCheck {
|
||||
if !conf.SSH.MinimumKeySizeCheck {
|
||||
return content, nil
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ func CheckPublicKeyString(content string) (_ string, err error) {
|
||||
keyType string
|
||||
length int
|
||||
)
|
||||
if setting.SSH.StartBuiltinServer {
|
||||
if conf.SSH.StartBuiltinServer {
|
||||
fnName = "SSHNativeParsePublicKey"
|
||||
keyType, length, err = SSHNativeParsePublicKey(content)
|
||||
} else {
|
||||
@@ -310,9 +310,9 @@ func CheckPublicKeyString(content string) (_ string, err error) {
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("%s: %v", fnName, err)
|
||||
}
|
||||
log.Trace("Key info [native: %v]: %s-%d", setting.SSH.StartBuiltinServer, keyType, length)
|
||||
log.Trace("Key info [native: %v]: %s-%d", conf.SSH.StartBuiltinServer, keyType, length)
|
||||
|
||||
if minLen, found := setting.SSH.MinimumKeySizes[keyType]; found && length >= minLen {
|
||||
if minLen, found := conf.SSH.MinimumKeySizes[keyType]; found && length >= minLen {
|
||||
return content, nil
|
||||
} else if found && length < minLen {
|
||||
return "", fmt.Errorf("key length is not enough: got %d, needs %d", length, minLen)
|
||||
@@ -325,7 +325,7 @@ func appendAuthorizedKeysToFile(keys ...*PublicKey) error {
|
||||
sshOpLocker.Lock()
|
||||
defer sshOpLocker.Unlock()
|
||||
|
||||
fpath := filepath.Join(setting.SSH.RootPath, "authorized_keys")
|
||||
fpath := filepath.Join(conf.SSH.RootPath, "authorized_keys")
|
||||
f, err := os.OpenFile(fpath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -333,7 +333,7 @@ func appendAuthorizedKeysToFile(keys ...*PublicKey) error {
|
||||
defer f.Close()
|
||||
|
||||
// Note: chmod command does not support in Windows.
|
||||
if !setting.IsWindows {
|
||||
if !conf.IsWindowsRuntime() {
|
||||
fi, err := f.Stat()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -375,12 +375,12 @@ func addKey(e Engine, key *PublicKey) (err error) {
|
||||
// Calculate fingerprint.
|
||||
tmpPath := strings.Replace(path.Join(os.TempDir(), fmt.Sprintf("%d", time.Now().Nanosecond()),
|
||||
"id_rsa.pub"), "\\", "/", -1)
|
||||
os.MkdirAll(path.Dir(tmpPath), os.ModePerm)
|
||||
_ = os.MkdirAll(path.Dir(tmpPath), os.ModePerm)
|
||||
if err = ioutil.WriteFile(tmpPath, []byte(key.Content), 0644); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
stdout, stderr, err := process.Exec("AddPublicKey", setting.SSH.KeygenPath, "-lf", tmpPath)
|
||||
stdout, stderr, err := process.Exec("AddPublicKey", conf.SSH.KeygenPath, "-lf", tmpPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("fail to parse public key: %s - %s", err, stderr)
|
||||
} else if len(stdout) < 2 {
|
||||
@@ -394,7 +394,7 @@ func addKey(e Engine, key *PublicKey) (err error) {
|
||||
}
|
||||
|
||||
// Don't need to rewrite this file if builtin SSH server is enabled.
|
||||
if setting.SSH.StartBuiltinServer {
|
||||
if conf.SSH.StartBuiltinServer {
|
||||
return nil
|
||||
}
|
||||
return appendAuthorizedKeysToFile(key)
|
||||
@@ -523,8 +523,8 @@ func RewriteAuthorizedKeys() error {
|
||||
|
||||
log.Trace("Doing: RewriteAuthorizedKeys")
|
||||
|
||||
os.MkdirAll(setting.SSH.RootPath, os.ModePerm)
|
||||
fpath := filepath.Join(setting.SSH.RootPath, "authorized_keys")
|
||||
_ = os.MkdirAll(conf.SSH.RootPath, os.ModePerm)
|
||||
fpath := filepath.Join(conf.SSH.RootPath, "authorized_keys")
|
||||
tmpPath := fpath + ".tmp"
|
||||
f, err := os.OpenFile(tmpPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
|
||||
if err != nil {
|
||||
@@ -536,7 +536,7 @@ func RewriteAuthorizedKeys() error {
|
||||
_, err = f.WriteString((bean.(*PublicKey)).AuthorizedString())
|
||||
return err
|
||||
})
|
||||
f.Close()
|
||||
_ = f.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -11,11 +11,11 @@ import (
|
||||
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
)
|
||||
|
||||
func init() {
|
||||
setting.Init()
|
||||
conf.MustInit("")
|
||||
}
|
||||
|
||||
func Test_SSHParsePublicKey(t *testing.T) {
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
"xorm.io/xorm"
|
||||
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
@@ -47,7 +47,7 @@ func (t *TwoFactor) ValidateTOTP(passcode string) (bool, error) {
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("DecodeString: %v", err)
|
||||
}
|
||||
decryptSecret, err := com.AESGCMDecrypt(tool.MD5Bytes(setting.SecretKey), secret)
|
||||
decryptSecret, err := com.AESGCMDecrypt(tool.MD5Bytes(conf.SecretKey), secret)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("AESGCMDecrypt: %v", err)
|
||||
}
|
||||
@@ -85,7 +85,7 @@ func NewTwoFactor(userID int64, secret string) error {
|
||||
}
|
||||
|
||||
// Encrypt secret
|
||||
encryptSecret, err := com.AESGCMEncrypt(tool.MD5Bytes(setting.SecretKey), []byte(secret))
|
||||
encryptSecret, err := com.AESGCMEncrypt(tool.MD5Bytes(conf.SecretKey), []byte(secret))
|
||||
if err != nil {
|
||||
return fmt.Errorf("AESGCMEncrypt: %v", err)
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ import (
|
||||
api "github.com/gogs/go-gogs-client"
|
||||
|
||||
"gogs.io/gogs/internal/avatar"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
@@ -152,23 +152,23 @@ func (u *User) HasForkedRepo(repoID int64) bool {
|
||||
|
||||
func (u *User) RepoCreationNum() int {
|
||||
if u.MaxRepoCreation <= -1 {
|
||||
return setting.Repository.MaxCreationLimit
|
||||
return conf.Repository.MaxCreationLimit
|
||||
}
|
||||
return u.MaxRepoCreation
|
||||
}
|
||||
|
||||
func (u *User) CanCreateRepo() bool {
|
||||
if u.MaxRepoCreation <= -1 {
|
||||
if setting.Repository.MaxCreationLimit <= -1 {
|
||||
if conf.Repository.MaxCreationLimit <= -1 {
|
||||
return true
|
||||
}
|
||||
return u.NumRepos < setting.Repository.MaxCreationLimit
|
||||
return u.NumRepos < conf.Repository.MaxCreationLimit
|
||||
}
|
||||
return u.NumRepos < u.MaxRepoCreation
|
||||
}
|
||||
|
||||
func (u *User) CanCreateOrganization() bool {
|
||||
return !setting.Admin.DisableRegularOrgCreation || u.IsAdmin
|
||||
return !conf.Admin.DisableRegularOrgCreation || u.IsAdmin
|
||||
}
|
||||
|
||||
// CanEditGitHook returns true if user can edit Git hooks.
|
||||
@@ -178,31 +178,31 @@ func (u *User) CanEditGitHook() bool {
|
||||
|
||||
// CanImportLocal returns true if user can migrate repository by local path.
|
||||
func (u *User) CanImportLocal() bool {
|
||||
return setting.Repository.EnableLocalPathMigration && (u.IsAdmin || u.AllowImportLocal)
|
||||
return conf.Repository.EnableLocalPathMigration && (u.IsAdmin || u.AllowImportLocal)
|
||||
}
|
||||
|
||||
// DashboardLink returns the user dashboard page link.
|
||||
func (u *User) DashboardLink() string {
|
||||
if u.IsOrganization() {
|
||||
return setting.AppSubURL + "/org/" + u.Name + "/dashboard/"
|
||||
return conf.Server.Subpath + "/org/" + u.Name + "/dashboard/"
|
||||
}
|
||||
return setting.AppSubURL + "/"
|
||||
return conf.Server.Subpath + "/"
|
||||
}
|
||||
|
||||
// HomeLink returns the user or organization home page link.
|
||||
func (u *User) HomeLink() string {
|
||||
return setting.AppSubURL + "/" + u.Name
|
||||
return conf.Server.Subpath + "/" + u.Name
|
||||
}
|
||||
|
||||
func (u *User) HTMLURL() string {
|
||||
return setting.AppURL + u.Name
|
||||
return conf.Server.ExternalURL + u.Name
|
||||
}
|
||||
|
||||
// GenerateEmailActivateCode generates an activate code based on user information and given e-mail.
|
||||
func (u *User) GenerateEmailActivateCode(email string) string {
|
||||
code := tool.CreateTimeLimitCode(
|
||||
com.ToStr(u.ID)+email+u.LowerName+u.Passwd+u.Rands,
|
||||
setting.Service.ActiveCodeLives, nil)
|
||||
conf.Service.ActiveCodeLives, nil)
|
||||
|
||||
// Add tail hex username
|
||||
code += hex.EncodeToString([]byte(u.LowerName))
|
||||
@@ -216,7 +216,7 @@ func (u *User) GenerateActivateCode() string {
|
||||
|
||||
// CustomAvatarPath returns user custom avatar file path.
|
||||
func (u *User) CustomAvatarPath() string {
|
||||
return filepath.Join(setting.AvatarUploadPath, com.ToStr(u.ID))
|
||||
return filepath.Join(conf.AvatarUploadPath, com.ToStr(u.ID))
|
||||
}
|
||||
|
||||
// GenerateRandomAvatar generates a random avatar for user.
|
||||
@@ -251,7 +251,7 @@ func (u *User) GenerateRandomAvatar() error {
|
||||
// which includes app sub-url as prefix. However, it is possible
|
||||
// to return full URL if user enables Gravatar-like service.
|
||||
func (u *User) RelAvatarLink() string {
|
||||
defaultImgUrl := setting.AppSubURL + "/img/avatar_default.png"
|
||||
defaultImgUrl := conf.Server.Subpath + "/img/avatar_default.png"
|
||||
if u.ID == -1 {
|
||||
return defaultImgUrl
|
||||
}
|
||||
@@ -261,15 +261,15 @@ func (u *User) RelAvatarLink() string {
|
||||
if !com.IsExist(u.CustomAvatarPath()) {
|
||||
return defaultImgUrl
|
||||
}
|
||||
return fmt.Sprintf("%s/%s/%d", setting.AppSubURL, USER_AVATAR_URL_PREFIX, u.ID)
|
||||
case setting.DisableGravatar, setting.OfflineMode:
|
||||
return fmt.Sprintf("%s/%s/%d", conf.Server.Subpath, USER_AVATAR_URL_PREFIX, u.ID)
|
||||
case conf.DisableGravatar:
|
||||
if !com.IsExist(u.CustomAvatarPath()) {
|
||||
if err := u.GenerateRandomAvatar(); err != nil {
|
||||
log.Error("GenerateRandomAvatar: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s/%s/%d", setting.AppSubURL, USER_AVATAR_URL_PREFIX, u.ID)
|
||||
return fmt.Sprintf("%s/%s/%d", conf.Server.Subpath, USER_AVATAR_URL_PREFIX, u.ID)
|
||||
}
|
||||
return tool.AvatarLink(u.AvatarEmail)
|
||||
}
|
||||
@@ -278,7 +278,7 @@ func (u *User) RelAvatarLink() string {
|
||||
func (u *User) AvatarLink() string {
|
||||
link := u.RelAvatarLink()
|
||||
if link[0] == '/' && link[1] != '/' {
|
||||
return setting.AppURL + strings.TrimPrefix(link, setting.AppSubURL)[1:]
|
||||
return conf.Server.ExternalURL + strings.TrimPrefix(link, conf.Server.Subpath)[1:]
|
||||
}
|
||||
return link
|
||||
}
|
||||
@@ -287,7 +287,7 @@ func (u *User) AvatarLink() string {
|
||||
func (u *User) GetFollowers(page int) ([]*User, error) {
|
||||
users := make([]*User, 0, ItemsPerPage)
|
||||
sess := x.Limit(ItemsPerPage, (page-1)*ItemsPerPage).Where("follow.follow_id=?", u.ID)
|
||||
if setting.UsePostgreSQL {
|
||||
if conf.UsePostgreSQL {
|
||||
sess = sess.Join("LEFT", "follow", `"user".id=follow.user_id`)
|
||||
} else {
|
||||
sess = sess.Join("LEFT", "follow", "user.id=follow.user_id")
|
||||
@@ -303,7 +303,7 @@ func (u *User) IsFollowing(followID int64) bool {
|
||||
func (u *User) GetFollowing(page int) ([]*User, error) {
|
||||
users := make([]*User, 0, ItemsPerPage)
|
||||
sess := x.Limit(ItemsPerPage, (page-1)*ItemsPerPage).Where("follow.user_id=?", u.ID)
|
||||
if setting.UsePostgreSQL {
|
||||
if conf.UsePostgreSQL {
|
||||
sess = sess.Join("LEFT", "follow", `"user".id=follow.follow_id`)
|
||||
} else {
|
||||
sess = sess.Join("LEFT", "follow", "user.id=follow.follow_id")
|
||||
@@ -341,7 +341,7 @@ func (u *User) UploadAvatar(data []byte) error {
|
||||
return fmt.Errorf("decode image: %v", err)
|
||||
}
|
||||
|
||||
os.MkdirAll(setting.AvatarUploadPath, os.ModePerm)
|
||||
_ = os.MkdirAll(conf.AvatarUploadPath, os.ModePerm)
|
||||
fw, err := os.Create(u.CustomAvatarPath())
|
||||
if err != nil {
|
||||
return fmt.Errorf("create custom avatar directory: %v", err)
|
||||
@@ -617,7 +617,7 @@ func parseUserFromCode(code string) (user *User) {
|
||||
|
||||
// verify active code when active account
|
||||
func VerifyUserActiveCode(code string) (user *User) {
|
||||
minutes := setting.Service.ActiveCodeLives
|
||||
minutes := conf.Service.ActiveCodeLives
|
||||
|
||||
if user = parseUserFromCode(code); user != nil {
|
||||
// time limit code
|
||||
@@ -633,7 +633,7 @@ func VerifyUserActiveCode(code string) (user *User) {
|
||||
|
||||
// verify active code when active account
|
||||
func VerifyActiveEmailCode(code, email string) *EmailAddress {
|
||||
minutes := setting.Service.ActiveCodeLives
|
||||
minutes := conf.Service.ActiveCodeLives
|
||||
|
||||
if user := parseUserFromCode(code); user != nil {
|
||||
// time limit code
|
||||
@@ -877,7 +877,7 @@ func DeleteInactivateUsers() (err error) {
|
||||
|
||||
// UserPath returns the path absolute path of user repositories.
|
||||
func UserPath(userName string) string {
|
||||
return filepath.Join(setting.RepoRootPath, strings.ToLower(userName))
|
||||
return filepath.Join(conf.RepoRootPath, strings.ToLower(userName))
|
||||
}
|
||||
|
||||
func GetUserByKeyID(keyID int64) (*User, error) {
|
||||
@@ -1049,8 +1049,8 @@ func SearchUserByName(opts *SearchUserOptions) (users []*User, _ int64, _ error)
|
||||
}
|
||||
opts.Keyword = strings.ToLower(opts.Keyword)
|
||||
|
||||
if opts.PageSize <= 0 || opts.PageSize > setting.UI.ExplorePagingNum {
|
||||
opts.PageSize = setting.UI.ExplorePagingNum
|
||||
if opts.PageSize <= 0 || opts.PageSize > conf.UI.ExplorePagingNum {
|
||||
opts.PageSize = conf.UI.ExplorePagingNum
|
||||
}
|
||||
if opts.Page <= 0 {
|
||||
opts.Page = 1
|
||||
|
||||
@@ -21,13 +21,13 @@ import (
|
||||
|
||||
api "github.com/gogs/go-gogs-client"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/httplib"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/sync"
|
||||
)
|
||||
|
||||
var HookQueue = sync.NewUniqueQueue(setting.Webhook.QueueLength)
|
||||
var HookQueue = sync.NewUniqueQueue(conf.Webhook.QueueLength)
|
||||
|
||||
type HookContentType int
|
||||
|
||||
@@ -99,7 +99,7 @@ type Webhook struct {
|
||||
ContentType HookContentType
|
||||
Secret string `xorm:"TEXT"`
|
||||
Events string `xorm:"TEXT"`
|
||||
*HookEvent `xorm:"-"` // LEGACY [1.0]: Cannot ignore JSON here, it breaks old backup archive
|
||||
*HookEvent `xorm:"-"` // LEGACY [1.0]: Cannot ignore JSON (i.e. json:"-") here, it breaks old backup archive
|
||||
IsSSL bool `xorm:"is_ssl"`
|
||||
IsActive bool
|
||||
HookTaskType HookTaskType
|
||||
@@ -482,8 +482,8 @@ func (t *HookTask) MarshalJSON(v interface{}) string {
|
||||
|
||||
// HookTasks returns a list of hook tasks by given conditions.
|
||||
func HookTasks(hookID int64, page int) ([]*HookTask, error) {
|
||||
tasks := make([]*HookTask, 0, setting.Webhook.PagingNum)
|
||||
return tasks, x.Limit(setting.Webhook.PagingNum, (page-1)*setting.Webhook.PagingNum).Where("hook_id=?", hookID).Desc("id").Find(&tasks)
|
||||
tasks := make([]*HookTask, 0, conf.Webhook.PagingNum)
|
||||
return tasks, x.Limit(conf.Webhook.PagingNum, (page-1)*conf.Webhook.PagingNum).Where("hook_id=?", hookID).Desc("id").Find(&tasks)
|
||||
}
|
||||
|
||||
// createHookTask creates a new hook task,
|
||||
@@ -652,14 +652,14 @@ func TestWebhook(repo *Repository, event HookEventType, p api.Payloader, webhook
|
||||
func (t *HookTask) deliver() {
|
||||
t.IsDelivered = true
|
||||
|
||||
timeout := time.Duration(setting.Webhook.DeliverTimeout) * time.Second
|
||||
timeout := time.Duration(conf.Webhook.DeliverTimeout) * time.Second
|
||||
req := httplib.Post(t.URL).SetTimeout(timeout, timeout).
|
||||
Header("X-Github-Delivery", t.UUID).
|
||||
Header("X-Github-Event", string(t.EventType)).
|
||||
Header("X-Gogs-Delivery", t.UUID).
|
||||
Header("X-Gogs-Signature", t.Signature).
|
||||
Header("X-Gogs-Event", string(t.EventType)).
|
||||
SetTLSClientConfig(&tls.Config{InsecureSkipVerify: setting.Webhook.SkipTLSVerify})
|
||||
SetTLSClientConfig(&tls.Config{InsecureSkipVerify: conf.Webhook.SkipTLSVerify})
|
||||
|
||||
switch t.ContentType {
|
||||
case JSON:
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/gogs/git-module"
|
||||
api "github.com/gogs/go-gogs-client"
|
||||
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
)
|
||||
|
||||
type DiscordEmbedFooterObject struct {
|
||||
@@ -78,7 +78,7 @@ func getDiscordCreatePayload(p *api.CreatePayload) (*DiscordPayload, error) {
|
||||
return &DiscordPayload{
|
||||
Embeds: []*DiscordEmbedObject{{
|
||||
Description: content,
|
||||
URL: setting.AppURL + p.Sender.UserName,
|
||||
URL: conf.Server.ExternalURL + p.Sender.UserName,
|
||||
Author: &DiscordEmbedAuthorObject{
|
||||
Name: p.Sender.UserName,
|
||||
IconURL: p.Sender.AvatarUrl,
|
||||
@@ -95,7 +95,7 @@ func getDiscordDeletePayload(p *api.DeletePayload) (*DiscordPayload, error) {
|
||||
return &DiscordPayload{
|
||||
Embeds: []*DiscordEmbedObject{{
|
||||
Description: content,
|
||||
URL: setting.AppURL + p.Sender.UserName,
|
||||
URL: conf.Server.ExternalURL + p.Sender.UserName,
|
||||
Author: &DiscordEmbedAuthorObject{
|
||||
Name: p.Sender.UserName,
|
||||
IconURL: p.Sender.AvatarUrl,
|
||||
@@ -112,7 +112,7 @@ func getDiscordForkPayload(p *api.ForkPayload) (*DiscordPayload, error) {
|
||||
return &DiscordPayload{
|
||||
Embeds: []*DiscordEmbedObject{{
|
||||
Description: content,
|
||||
URL: setting.AppURL + p.Sender.UserName,
|
||||
URL: conf.Server.ExternalURL + p.Sender.UserName,
|
||||
Author: &DiscordEmbedAuthorObject{
|
||||
Name: p.Sender.UserName,
|
||||
IconURL: p.Sender.AvatarUrl,
|
||||
@@ -160,7 +160,7 @@ func getDiscordPushPayload(p *api.PushPayload, slack *SlackMeta) (*DiscordPayloa
|
||||
AvatarURL: slack.IconURL,
|
||||
Embeds: []*DiscordEmbedObject{{
|
||||
Description: content,
|
||||
URL: setting.AppURL + p.Sender.UserName,
|
||||
URL: conf.Server.ExternalURL + p.Sender.UserName,
|
||||
Color: int(color),
|
||||
Author: &DiscordEmbedAuthorObject{
|
||||
Name: p.Sender.UserName,
|
||||
@@ -361,7 +361,7 @@ func getDiscordReleasePayload(p *api.ReleasePayload) (*DiscordPayload, error) {
|
||||
return &DiscordPayload{
|
||||
Embeds: []*DiscordEmbedObject{{
|
||||
Description: content,
|
||||
URL: setting.AppURL + p.Sender.UserName,
|
||||
URL: conf.Server.ExternalURL + p.Sender.UserName,
|
||||
Author: &DiscordEmbedAuthorObject{
|
||||
Name: p.Sender.UserName,
|
||||
IconURL: p.Sender.AvatarUrl,
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/gogs/git-module"
|
||||
api "github.com/gogs/go-gogs-client"
|
||||
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
)
|
||||
|
||||
type SlackMeta struct {
|
||||
@@ -147,7 +147,7 @@ func getSlackPushPayload(p *api.PushPayload, slack *SlackMeta) (*SlackPayload, e
|
||||
}
|
||||
|
||||
func getSlackIssuesPayload(p *api.IssuesPayload, slack *SlackMeta) (*SlackPayload, error) {
|
||||
senderLink := SlackLinkFormatter(setting.AppURL+p.Sender.UserName, p.Sender.UserName)
|
||||
senderLink := SlackLinkFormatter(conf.Server.ExternalURL+p.Sender.UserName, p.Sender.UserName)
|
||||
titleLink := SlackLinkFormatter(fmt.Sprintf("%s/issues/%d", p.Repository.HTMLURL, p.Index),
|
||||
fmt.Sprintf("#%d %s", p.Index, p.Issue.Title))
|
||||
var text, title, attachmentText string
|
||||
@@ -165,7 +165,7 @@ func getSlackIssuesPayload(p *api.IssuesPayload, slack *SlackMeta) (*SlackPayloa
|
||||
attachmentText = SlackTextFormatter(p.Issue.Body)
|
||||
case api.HOOK_ISSUE_ASSIGNED:
|
||||
text = fmt.Sprintf("[%s] Issue assigned to %s: %s by %s", p.Repository.FullName,
|
||||
SlackLinkFormatter(setting.AppURL+p.Issue.Assignee.UserName, p.Issue.Assignee.UserName),
|
||||
SlackLinkFormatter(conf.Server.ExternalURL+p.Issue.Assignee.UserName, p.Issue.Assignee.UserName),
|
||||
titleLink, senderLink)
|
||||
case api.HOOK_ISSUE_UNASSIGNED:
|
||||
text = fmt.Sprintf("[%s] Issue unassigned: %s by %s", p.Repository.FullName, titleLink, senderLink)
|
||||
@@ -193,7 +193,7 @@ func getSlackIssuesPayload(p *api.IssuesPayload, slack *SlackMeta) (*SlackPayloa
|
||||
}
|
||||
|
||||
func getSlackIssueCommentPayload(p *api.IssueCommentPayload, slack *SlackMeta) (*SlackPayload, error) {
|
||||
senderLink := SlackLinkFormatter(setting.AppURL+p.Sender.UserName, p.Sender.UserName)
|
||||
senderLink := SlackLinkFormatter(conf.Server.ExternalURL+p.Sender.UserName, p.Sender.UserName)
|
||||
titleLink := SlackLinkFormatter(fmt.Sprintf("%s/issues/%d#%s", p.Repository.HTMLURL, p.Issue.Index, CommentHashTag(p.Comment.ID)),
|
||||
fmt.Sprintf("#%d %s", p.Issue.Index, p.Issue.Title))
|
||||
var text, title, attachmentText string
|
||||
@@ -227,7 +227,7 @@ func getSlackIssueCommentPayload(p *api.IssueCommentPayload, slack *SlackMeta) (
|
||||
}
|
||||
|
||||
func getSlackPullRequestPayload(p *api.PullRequestPayload, slack *SlackMeta) (*SlackPayload, error) {
|
||||
senderLink := SlackLinkFormatter(setting.AppURL+p.Sender.UserName, p.Sender.UserName)
|
||||
senderLink := SlackLinkFormatter(conf.Server.ExternalURL+p.Sender.UserName, p.Sender.UserName)
|
||||
titleLink := SlackLinkFormatter(fmt.Sprintf("%s/pulls/%d", p.Repository.HTMLURL, p.Index),
|
||||
fmt.Sprintf("#%d %s", p.Index, p.PullRequest.Title))
|
||||
var text, title, attachmentText string
|
||||
@@ -249,7 +249,7 @@ func getSlackPullRequestPayload(p *api.PullRequestPayload, slack *SlackMeta) (*S
|
||||
attachmentText = SlackTextFormatter(p.PullRequest.Body)
|
||||
case api.HOOK_ISSUE_ASSIGNED:
|
||||
text = fmt.Sprintf("[%s] Pull request assigned to %s: %s by %s", p.Repository.FullName,
|
||||
SlackLinkFormatter(setting.AppURL+p.PullRequest.Assignee.UserName, p.PullRequest.Assignee.UserName),
|
||||
SlackLinkFormatter(conf.Server.ExternalURL+p.PullRequest.Assignee.UserName, p.PullRequest.Assignee.UserName),
|
||||
titleLink, senderLink)
|
||||
case api.HOOK_ISSUE_UNASSIGNED:
|
||||
text = fmt.Sprintf("[%s] Pull request unassigned: %s by %s", p.Repository.FullName, titleLink, senderLink)
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
|
||||
"github.com/gogs/git-module"
|
||||
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/sync"
|
||||
)
|
||||
|
||||
@@ -71,7 +71,7 @@ func (repo *Repository) InitWiki() error {
|
||||
}
|
||||
|
||||
func (repo *Repository) LocalWikiPath() string {
|
||||
return path.Join(setting.AppDataPath, "tmp/local-wiki", com.ToStr(repo.ID))
|
||||
return filepath.Join(conf.Server.AppDataPath, "tmp", "local-wiki", com.ToStr(repo.ID))
|
||||
}
|
||||
|
||||
// UpdateLocalWiki makes sure the local copy of repository wiki is up-to-date.
|
||||
|
||||
Reference in New Issue
Block a user