aboutsummaryrefslogtreecommitdiff
path: root/internal/route/repo
diff options
context:
space:
mode:
Diffstat (limited to 'internal/route/repo')
-rw-r--r--internal/route/repo/commit.go22
-rw-r--r--internal/route/repo/download.go4
-rw-r--r--internal/route/repo/editor.go26
-rw-r--r--internal/route/repo/http.go12
-rw-r--r--internal/route/repo/issue.go36
-rw-r--r--internal/route/repo/pull.go24
-rw-r--r--internal/route/repo/release.go18
-rw-r--r--internal/route/repo/repo.go14
-rw-r--r--internal/route/repo/setting.go16
-rw-r--r--internal/route/repo/view.go8
-rw-r--r--internal/route/repo/webhook.go6
11 files changed, 93 insertions, 93 deletions
diff --git a/internal/route/repo/commit.go b/internal/route/repo/commit.go
index e058afc4..95075fb6 100644
--- a/internal/route/repo/commit.go
+++ b/internal/route/repo/commit.go
@@ -10,9 +10,9 @@ import (
"github.com/gogs/git-module"
+ "gogs.io/gogs/internal/conf"
"gogs.io/gogs/internal/context"
"gogs.io/gogs/internal/db"
- "gogs.io/gogs/internal/setting"
"gogs.io/gogs/internal/tool"
)
@@ -135,8 +135,8 @@ func Diff(c *context.Context) {
}
diff, err := db.GetDiffCommit(db.RepoPath(userName, repoName),
- commitID, setting.Git.MaxGitDiffLines,
- setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles)
+ commitID, conf.Git.MaxGitDiffLines,
+ conf.Git.MaxGitDiffLineCharacters, conf.Git.MaxGitDiffFiles)
if err != nil {
c.NotFoundOrServerError("get diff commit", git.IsErrNotExist, err)
return
@@ -168,11 +168,11 @@ func Diff(c *context.Context) {
c.Data["Diff"] = diff
c.Data["Parents"] = parents
c.Data["DiffNotAvailable"] = diff.NumFiles() == 0
- c.Data["SourcePath"] = setting.AppSubURL + "/" + path.Join(userName, repoName, "src", commitID)
+ c.Data["SourcePath"] = conf.Server.Subpath + "/" + path.Join(userName, repoName, "src", commitID)
if commit.ParentCount() > 0 {
- c.Data["BeforeSourcePath"] = setting.AppSubURL + "/" + path.Join(userName, repoName, "src", parents[0])
+ c.Data["BeforeSourcePath"] = conf.Server.Subpath + "/" + path.Join(userName, repoName, "src", parents[0])
}
- c.Data["RawPath"] = setting.AppSubURL + "/" + path.Join(userName, repoName, "raw", commitID)
+ c.Data["RawPath"] = conf.Server.Subpath + "/" + path.Join(userName, repoName, "raw", commitID)
c.Success(DIFF)
}
@@ -202,8 +202,8 @@ func CompareDiff(c *context.Context) {
}
diff, err := db.GetDiffRange(db.RepoPath(userName, repoName), beforeCommitID,
- afterCommitID, setting.Git.MaxGitDiffLines,
- setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles)
+ afterCommitID, conf.Git.MaxGitDiffLines,
+ conf.Git.MaxGitDiffLineCharacters, conf.Git.MaxGitDiffFiles)
if err != nil {
c.Handle(404, "GetDiffRange", err)
return
@@ -229,8 +229,8 @@ func CompareDiff(c *context.Context) {
c.Data["Commit"] = commit
c.Data["Diff"] = diff
c.Data["DiffNotAvailable"] = diff.NumFiles() == 0
- c.Data["SourcePath"] = setting.AppSubURL + "/" + path.Join(userName, repoName, "src", afterCommitID)
- c.Data["BeforeSourcePath"] = setting.AppSubURL + "/" + path.Join(userName, repoName, "src", beforeCommitID)
- c.Data["RawPath"] = setting.AppSubURL + "/" + path.Join(userName, repoName, "raw", afterCommitID)
+ c.Data["SourcePath"] = conf.Server.Subpath + "/" + path.Join(userName, repoName, "src", afterCommitID)
+ c.Data["BeforeSourcePath"] = conf.Server.Subpath + "/" + path.Join(userName, repoName, "src", beforeCommitID)
+ c.Data["RawPath"] = conf.Server.Subpath + "/" + path.Join(userName, repoName, "raw", afterCommitID)
c.HTML(200, DIFF)
}
diff --git a/internal/route/repo/download.go b/internal/route/repo/download.go
index 65c3c125..b75bcb9f 100644
--- a/internal/route/repo/download.go
+++ b/internal/route/repo/download.go
@@ -13,7 +13,7 @@ import (
"github.com/gogs/git-module"
"gogs.io/gogs/internal/context"
- "gogs.io/gogs/internal/setting"
+ "gogs.io/gogs/internal/conf"
"gogs.io/gogs/internal/tool"
)
@@ -35,7 +35,7 @@ func serveData(c *context.Context, name string, r io.Reader) error {
c.Resp.Header().Set("Content-Disposition", "attachment; filename=\""+name+"\"")
c.Resp.Header().Set("Content-Transfer-Encoding", "binary")
}
- } else if !setting.Repository.EnableRawFileRenderMode || !c.QueryBool("render") {
+ } else if !conf.Repository.EnableRawFileRenderMode || !c.QueryBool("render") {
c.Resp.Header().Set("Content-Type", "text/plain; charset=utf-8")
}
diff --git a/internal/route/repo/editor.go b/internal/route/repo/editor.go
index 75254a2e..7b7a0935 100644
--- a/internal/route/repo/editor.go
+++ b/internal/route/repo/editor.go
@@ -14,12 +14,12 @@ import (
log "unknwon.dev/clog/v2"
"github.com/gogs/git-module"
+ "gogs.io/gogs/internal/conf"
"gogs.io/gogs/internal/context"
"gogs.io/gogs/internal/db"
"gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/internal/form"
"gogs.io/gogs/internal/pathutil"
- "gogs.io/gogs/internal/setting"
"gogs.io/gogs/internal/template"
"gogs.io/gogs/internal/tool"
)
@@ -110,10 +110,10 @@ func editFile(c *context.Context, isNewFile bool) {
c.Data["commit_choice"] = "direct"
c.Data["new_branch_name"] = ""
c.Data["last_commit"] = c.Repo.Commit.ID
- c.Data["MarkdownFileExts"] = strings.Join(setting.Markdown.FileExtensions, ",")
- c.Data["LineWrapExtensions"] = strings.Join(setting.Repository.Editor.LineWrapExtensions, ",")
- c.Data["PreviewableFileModes"] = strings.Join(setting.Repository.Editor.PreviewableFileModes, ",")
- c.Data["EditorconfigURLPrefix"] = fmt.Sprintf("%s/api/v1/repos/%s/editorconfig/", setting.AppSubURL, c.Repo.Repository.FullName())
+ c.Data["MarkdownFileExts"] = strings.Join(conf.Markdown.FileExtensions, ",")
+ c.Data["LineWrapExtensions"] = strings.Join(conf.Repository.Editor.LineWrapExtensions, ",")
+ c.Data["PreviewableFileModes"] = strings.Join(conf.Repository.Editor.PreviewableFileModes, ",")
+ c.Data["EditorconfigURLPrefix"] = fmt.Sprintf("%s/api/v1/repos/%s/editorconfig/", conf.Server.Subpath, c.Repo.Repository.FullName())
c.Success(EDIT_FILE)
}
@@ -156,9 +156,9 @@ func editFilePost(c *context.Context, f form.EditRepoFile, isNewFile bool) {
c.Data["commit_choice"] = f.CommitChoice
c.Data["new_branch_name"] = branchName
c.Data["last_commit"] = f.LastCommit
- c.Data["MarkdownFileExts"] = strings.Join(setting.Markdown.FileExtensions, ",")
- c.Data["LineWrapExtensions"] = strings.Join(setting.Repository.Editor.LineWrapExtensions, ",")
- c.Data["PreviewableFileModes"] = strings.Join(setting.Repository.Editor.PreviewableFileModes, ",")
+ c.Data["MarkdownFileExts"] = strings.Join(conf.Markdown.FileExtensions, ",")
+ c.Data["LineWrapExtensions"] = strings.Join(conf.Repository.Editor.LineWrapExtensions, ",")
+ c.Data["PreviewableFileModes"] = strings.Join(conf.Repository.Editor.PreviewableFileModes, ",")
if c.HasError() {
c.Success(EDIT_FILE)
@@ -400,9 +400,9 @@ func DeleteFilePost(c *context.Context, f form.DeleteRepoFile) {
func renderUploadSettings(c *context.Context) {
c.RequireDropzone()
- c.Data["UploadAllowedTypes"] = strings.Join(setting.Repository.Upload.AllowedTypes, ",")
- c.Data["UploadMaxSize"] = setting.Repository.Upload.FileMaxSize
- c.Data["UploadMaxFiles"] = setting.Repository.Upload.MaxFiles
+ c.Data["UploadAllowedTypes"] = strings.Join(conf.Repository.Upload.AllowedTypes, ",")
+ c.Data["UploadMaxSize"] = conf.Repository.Upload.FileMaxSize
+ c.Data["UploadMaxFiles"] = conf.Repository.Upload.MaxFiles
}
func UploadFile(c *context.Context) {
@@ -533,9 +533,9 @@ func UploadFileToServer(c *context.Context) {
}
fileType := http.DetectContentType(buf)
- if len(setting.Repository.Upload.AllowedTypes) > 0 {
+ if len(conf.Repository.Upload.AllowedTypes) > 0 {
allowed := false
- for _, t := range setting.Repository.Upload.AllowedTypes {
+ for _, t := range conf.Repository.Upload.AllowedTypes {
t := strings.Trim(t, " ")
if t == "*/*" || t == fileType {
allowed = true
diff --git a/internal/route/repo/http.go b/internal/route/repo/http.go
index be80d379..9b780dde 100644
--- a/internal/route/repo/http.go
+++ b/internal/route/repo/http.go
@@ -23,7 +23,7 @@ import (
"gogs.io/gogs/internal/db"
"gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/internal/lazyregexp"
- "gogs.io/gogs/internal/setting"
+ "gogs.io/gogs/internal/conf"
"gogs.io/gogs/internal/tool"
)
@@ -44,9 +44,9 @@ func askCredentials(c *context.Context, status int, text string) {
func HTTPContexter() macaron.Handler {
return func(c *context.Context) {
- if len(setting.HTTP.AccessControlAllowOrigin) > 0 {
+ if len(conf.HTTP.AccessControlAllowOrigin) > 0 {
// Set CORS headers for browser-based git clients
- c.Resp.Header().Set("Access-Control-Allow-Origin", setting.HTTP.AccessControlAllowOrigin)
+ c.Resp.Header().Set("Access-Control-Allow-Origin", conf.HTTP.AccessControlAllowOrigin)
c.Resp.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization, User-Agent")
// Handle preflight OPTIONS request
@@ -77,7 +77,7 @@ func HTTPContexter() macaron.Handler {
}
// Authentication is not required for pulling from public repositories.
- if isPull && !repo.IsPrivate && !setting.Service.RequireSignInView {
+ if isPull && !repo.IsPrivate && !conf.Service.RequireSignInView {
c.Map(&HTTPContext{
Context: c,
})
@@ -368,7 +368,7 @@ func getGitRepoPath(dir string) (string, error) {
dir += ".git"
}
- filename := path.Join(setting.RepoRootPath, dir)
+ filename := path.Join(conf.RepoRootPath, dir)
if _, err := os.Stat(filename); os.IsNotExist(err) {
return "", err
}
@@ -387,7 +387,7 @@ func HTTP(c *HTTPContext) {
// We perform check here because route matched in cmd/web.go is wider than needed,
// but we only want to output this message only if user is really trying to access
// Git HTTP endpoints.
- if setting.Repository.DisableHTTPGit {
+ if conf.Repository.DisableHTTPGit {
c.HandleText(http.StatusForbidden, "Interacting with repositories by HTTP protocol is not disabled")
return
}
diff --git a/internal/route/repo/issue.go b/internal/route/repo/issue.go
index 76c63363..2cc065e0 100644
--- a/internal/route/repo/issue.go
+++ b/internal/route/repo/issue.go
@@ -17,12 +17,12 @@ import (
"github.com/unknwon/paginater"
log "unknwon.dev/clog/v2"
+ "gogs.io/gogs/internal/conf"
"gogs.io/gogs/internal/context"
"gogs.io/gogs/internal/db"
"gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/internal/form"
"gogs.io/gogs/internal/markup"
- "gogs.io/gogs/internal/setting"
"gogs.io/gogs/internal/tool"
)
@@ -116,8 +116,8 @@ func issues(c *context.Context, isPullList bool) {
// Must sign in to see issues about you.
if viewType != "all" && !c.IsLogged {
- c.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppSubURL+c.Req.RequestURI), 0, setting.AppSubURL)
- c.Redirect(setting.AppSubURL + "/user/login")
+ c.SetCookie("redirect_to", "/"+url.QueryEscape(conf.Server.Subpath+c.Req.RequestURI), 0, conf.Server.Subpath)
+ c.Redirect(conf.Server.Subpath + "/user/login")
return
}
@@ -167,7 +167,7 @@ func issues(c *context.Context, isPullList bool) {
} else {
total = int(issueStats.ClosedCount)
}
- pager := paginater.New(total, setting.UI.IssuePagingNum, page, 5)
+ pager := paginater.New(total, conf.UI.IssuePagingNum, page, 5)
c.Data["Page"] = pager
issues, err := db.Issues(&db.IssuesOptions{
@@ -256,10 +256,10 @@ func Pulls(c *context.Context) {
func renderAttachmentSettings(c *context.Context) {
c.Data["RequireDropzone"] = true
- c.Data["IsAttachmentEnabled"] = setting.AttachmentEnabled
- c.Data["AttachmentAllowedTypes"] = setting.AttachmentAllowedTypes
- c.Data["AttachmentMaxSize"] = setting.AttachmentMaxSize
- c.Data["AttachmentMaxFiles"] = setting.AttachmentMaxFiles
+ c.Data["IsAttachmentEnabled"] = conf.AttachmentEnabled
+ c.Data["AttachmentAllowedTypes"] = conf.AttachmentAllowedTypes
+ c.Data["AttachmentMaxSize"] = conf.AttachmentMaxSize
+ c.Data["AttachmentMaxFiles"] = conf.AttachmentMaxFiles
}
func RetrieveRepoMilestonesAndAssignees(c *context.Context, repo *db.Repository) {
@@ -429,7 +429,7 @@ func NewIssuePost(c *context.Context, f form.NewIssue) {
}
var attachments []string
- if setting.AttachmentEnabled {
+ if conf.AttachmentEnabled {
attachments = f.Files
}
@@ -493,12 +493,12 @@ func uploadAttachment(c *context.Context, allowedTypes []string) {
}
func UploadIssueAttachment(c *context.Context) {
- if !setting.AttachmentEnabled {
+ if !conf.AttachmentEnabled {
c.NotFound()
return
}
- uploadAttachment(c, strings.Split(setting.AttachmentAllowedTypes, ","))
+ uploadAttachment(c, strings.Split(conf.AttachmentAllowedTypes, ","))
}
func viewIssue(c *context.Context, isPullList bool) {
@@ -669,7 +669,7 @@ func viewIssue(c *context.Context, isPullList bool) {
c.Data["NumParticipants"] = len(participants)
c.Data["Issue"] = issue
c.Data["IsIssueOwner"] = c.Repo.IsWriter() || (c.IsLogged && issue.IsPoster(c.User.ID))
- c.Data["SignInLink"] = setting.AppSubURL + "/user/login?redirect_to=" + c.Data["Link"].(string)
+ c.Data["SignInLink"] = conf.Server.Subpath + "/user/login?redirect_to=" + c.Data["Link"].(string)
c.HTML(200, ISSUE_VIEW)
}
@@ -845,7 +845,7 @@ func NewComment(c *context.Context, f form.CreateComment) {
}
var attachments []string
- if setting.AttachmentEnabled {
+ if conf.AttachmentEnabled {
attachments = f.Files
}
@@ -1098,7 +1098,7 @@ func Milestones(c *context.Context) {
} else {
total = int(closedCount)
}
- c.Data["Page"] = paginater.New(total, setting.UI.IssuePagingNum, page, 5)
+ c.Data["Page"] = paginater.New(total, conf.UI.IssuePagingNum, page, 5)
miles, err := db.GetMilestones(c.Repo.Repository.ID, page, isShowClosed)
if err != nil {
@@ -1130,7 +1130,7 @@ func NewMilestone(c *context.Context) {
c.Data["PageIsIssueList"] = true
c.Data["PageIsMilestones"] = true
c.Data["RequireDatetimepicker"] = true
- c.Data["DateLang"] = setting.DateLang(c.Locale.Language())
+ c.Data["DateLang"] = conf.DateLang(c.Locale.Language())
c.HTML(200, MILESTONE_NEW)
}
@@ -1139,7 +1139,7 @@ func NewMilestonePost(c *context.Context, f form.CreateMilestone) {
c.Data["PageIsIssueList"] = true
c.Data["PageIsMilestones"] = true
c.Data["RequireDatetimepicker"] = true
- c.Data["DateLang"] = setting.DateLang(c.Locale.Language())
+ c.Data["DateLang"] = conf.DateLang(c.Locale.Language())
if c.HasError() {
c.HTML(200, MILESTONE_NEW)
@@ -1175,7 +1175,7 @@ func EditMilestone(c *context.Context) {
c.Data["PageIsMilestones"] = true
c.Data["PageIsEditMilestone"] = true
c.Data["RequireDatetimepicker"] = true
- c.Data["DateLang"] = setting.DateLang(c.Locale.Language())
+ c.Data["DateLang"] = conf.DateLang(c.Locale.Language())
m, err := db.GetMilestoneByRepoID(c.Repo.Repository.ID, c.ParamsInt64(":id"))
if err != nil {
@@ -1199,7 +1199,7 @@ func EditMilestonePost(c *context.Context, f form.CreateMilestone) {
c.Data["PageIsMilestones"] = true
c.Data["PageIsEditMilestone"] = true
c.Data["RequireDatetimepicker"] = true
- c.Data["DateLang"] = setting.DateLang(c.Locale.Language())
+ c.Data["DateLang"] = conf.DateLang(c.Locale.Language())
if c.HasError() {
c.HTML(200, MILESTONE_NEW)
diff --git a/internal/route/repo/pull.go b/internal/route/repo/pull.go
index d2cb52cb..52e7281a 100644
--- a/internal/route/repo/pull.go
+++ b/internal/route/repo/pull.go
@@ -14,11 +14,11 @@ import (
"github.com/gogs/git-module"
+ "gogs.io/gogs/internal/conf"
"gogs.io/gogs/internal/context"
"gogs.io/gogs/internal/db"
"gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/internal/form"
- "gogs.io/gogs/internal/setting"
"gogs.io/gogs/internal/tool"
)
@@ -354,8 +354,8 @@ func ViewPullFiles(c *context.Context) {
}
diff, err := db.GetDiffRange(diffRepoPath,
- startCommitID, endCommitID, setting.Git.MaxGitDiffLines,
- setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles)
+ startCommitID, endCommitID, conf.Git.MaxGitDiffLines,
+ conf.Git.MaxGitDiffLineCharacters, conf.Git.MaxGitDiffFiles)
if err != nil {
c.ServerError("GetDiffRange", err)
return
@@ -383,9 +383,9 @@ func ViewPullFiles(c *context.Context) {
c.Data["Reponame"] = pull.HeadRepo.Name
headTarget := path.Join(pull.HeadUserName, pull.HeadRepo.Name)
- c.Data["SourcePath"] = setting.AppSubURL + "/" + path.Join(headTarget, "src", endCommitID)
- c.Data["BeforeSourcePath"] = setting.AppSubURL + "/" + path.Join(headTarget, "src", startCommitID)
- c.Data["RawPath"] = setting.AppSubURL + "/" + path.Join(headTarget, "raw", endCommitID)
+ c.Data["SourcePath"] = conf.Server.Subpath + "/" + path.Join(headTarget, "src", endCommitID)
+ c.Data["BeforeSourcePath"] = conf.Server.Subpath + "/" + path.Join(headTarget, "src", startCommitID)
+ c.Data["RawPath"] = conf.Server.Subpath + "/" + path.Join(headTarget, "raw", endCommitID)
}
c.Data["RequireHighlightJS"] = true
@@ -570,8 +570,8 @@ func PrepareCompareDiff(
}
diff, err := db.GetDiffRange(db.RepoPath(headUser.Name, headRepo.Name),
- prInfo.MergeBase, headCommitID, setting.Git.MaxGitDiffLines,
- setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles)
+ prInfo.MergeBase, headCommitID, conf.Git.MaxGitDiffLines,
+ conf.Git.MaxGitDiffLineCharacters, conf.Git.MaxGitDiffFiles)
if err != nil {
c.ServerError("GetDiffRange", err)
return false
@@ -593,9 +593,9 @@ func PrepareCompareDiff(
c.Data["IsImageFile"] = headCommit.IsImageFile
headTarget := path.Join(headUser.Name, repo.Name)
- c.Data["SourcePath"] = setting.AppSubURL + "/" + path.Join(headTarget, "src", headCommitID)
- c.Data["BeforeSourcePath"] = setting.AppSubURL + "/" + path.Join(headTarget, "src", prInfo.MergeBase)
- c.Data["RawPath"] = setting.AppSubURL + "/" + path.Join(headTarget, "raw", headCommitID)
+ c.Data["SourcePath"] = conf.Server.Subpath + "/" + path.Join(headTarget, "src", headCommitID)
+ c.Data["BeforeSourcePath"] = conf.Server.Subpath + "/" + path.Join(headTarget, "src", prInfo.MergeBase)
+ c.Data["RawPath"] = conf.Server.Subpath + "/" + path.Join(headTarget, "raw", headCommitID)
return false
}
@@ -677,7 +677,7 @@ func CompareAndPullRequestPost(c *context.Context, f form.NewIssue) {
return
}
- if setting.AttachmentEnabled {
+ if conf.AttachmentEnabled {
attachments = f.Files
}
diff --git a/internal/route/repo/release.go b/internal/route/repo/release.go
index d7c5aec3..282aa053 100644
--- a/internal/route/repo/release.go
+++ b/internal/route/repo/release.go
@@ -14,7 +14,7 @@ import (
"gogs.io/gogs/internal/db"
"gogs.io/gogs/internal/form"
"gogs.io/gogs/internal/markup"
- "gogs.io/gogs/internal/setting"
+ "gogs.io/gogs/internal/conf"
)
const (
@@ -151,10 +151,10 @@ func Releases(c *context.Context) {
func renderReleaseAttachmentSettings(c *context.Context) {
c.Data["RequireDropzone"] = true
- c.Data["IsAttachmentEnabled"] = setting.Release.Attachment.Enabled
- c.Data["AttachmentAllowedTypes"] = strings.Join(setting.Release.Attachment.AllowedTypes, ",")
- c.Data["AttachmentMaxSize"] = setting.Release.Attachment.MaxSize
- c.Data["AttachmentMaxFiles"] = setting.Release.Attachment.MaxFiles
+ c.Data["IsAttachmentEnabled"] = conf.Release.Attachment.Enabled
+ c.Data["AttachmentAllowedTypes"] = strings.Join(conf.Release.Attachment.AllowedTypes, ",")
+ c.Data["AttachmentMaxSize"] = conf.Release.Attachment.MaxSize
+ c.Data["AttachmentMaxFiles"] = conf.Release.Attachment.MaxFiles
}
func NewRelease(c *context.Context) {
@@ -203,7 +203,7 @@ func NewReleasePost(c *context.Context, f form.NewRelease) {
}
var attachments []string
- if setting.Release.Attachment.Enabled {
+ if conf.Release.Attachment.Enabled {
attachments = f.Files
}
@@ -295,7 +295,7 @@ func EditReleasePost(c *context.Context, f form.EditRelease) {
}
var attachments []string
- if setting.Release.Attachment.Enabled {
+ if conf.Release.Attachment.Enabled {
attachments = f.Files
}
@@ -312,11 +312,11 @@ func EditReleasePost(c *context.Context, f form.EditRelease) {
}
func UploadReleaseAttachment(c *context.Context) {
- if !setting.Release.Attachment.Enabled {
+ if !conf.Release.Attachment.Enabled {
c.NotFound()
return
}
- uploadAttachment(c, setting.Release.Attachment.AllowedTypes)
+ uploadAttachment(c, conf.Release.Attachment.AllowedTypes)
}
func DeleteRelease(c *context.Context) {
diff --git a/internal/route/repo/repo.go b/internal/route/repo/repo.go
index 7d906242..7f7c2bce 100644
--- a/internal/route/repo/repo.go
+++ b/internal/route/repo/repo.go
@@ -15,11 +15,11 @@ import (
"github.com/gogs/git-module"
+ "gogs.io/gogs/internal/conf"
"gogs.io/gogs/internal/context"
"gogs.io/gogs/internal/db"
"gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/internal/form"
- "gogs.io/gogs/internal/setting"
"gogs.io/gogs/internal/tool"
)
@@ -75,7 +75,7 @@ func Create(c *context.Context) {
c.Data["Readmes"] = db.Readmes
c.Data["readme"] = "Default"
c.Data["private"] = c.User.LastRepoVisibility
- c.Data["IsForcedPrivate"] = setting.Repository.ForcePrivate
+ c.Data["IsForcedPrivate"] = conf.Repository.ForcePrivate
ctxUser := checkContextUser(c, c.QueryInt64("org"))
if c.Written() {
@@ -128,12 +128,12 @@ func CreatePost(c *context.Context, f form.CreateRepo) {
Gitignores: f.Gitignores,
License: f.License,
Readme: f.Readme,
- IsPrivate: f.Private || setting.Repository.ForcePrivate,
+ IsPrivate: f.Private || conf.Repository.ForcePrivate,
AutoInit: f.AutoInit,
})
if err == nil {
log.Trace("Repository created [%d]: %s/%s", repo.ID, ctxUser.Name, repo.Name)
- c.Redirect(setting.AppSubURL + "/" + ctxUser.Name + "/" + repo.Name)
+ c.Redirect(conf.Server.Subpath + "/" + ctxUser.Name + "/" + repo.Name)
return
}
@@ -149,7 +149,7 @@ func CreatePost(c *context.Context, f form.CreateRepo) {
func Migrate(c *context.Context) {
c.Data["Title"] = c.Tr("new_migrate")
c.Data["private"] = c.User.LastRepoVisibility
- c.Data["IsForcedPrivate"] = setting.Repository.ForcePrivate
+ c.Data["IsForcedPrivate"] = conf.Repository.ForcePrivate
c.Data["mirror"] = c.Query("mirror") == "1"
ctxUser := checkContextUser(c, c.QueryInt64("org"))
@@ -199,13 +199,13 @@ func MigratePost(c *context.Context, f form.MigrateRepo) {
repo, err := db.MigrateRepository(c.User, ctxUser, db.MigrateRepoOptions{
Name: f.RepoName,
Description: f.Description,
- IsPrivate: f.Private || setting.Repository.ForcePrivate,
+ IsPrivate: f.Private || conf.Repository.ForcePrivate,
IsMirror: f.Mirror,
RemoteAddr: remoteAddr,
})
if err == nil {
log.Trace("Repository migrated [%d]: %s/%s", repo.ID, ctxUser.Name, f.RepoName)
- c.Redirect(setting.AppSubURL + "/" + ctxUser.Name + "/" + f.RepoName)
+ c.Redirect(conf.Server.Subpath + "/" + ctxUser.Name + "/" + f.RepoName)
return
}
diff --git a/internal/route/repo/setting.go b/internal/route/repo/setting.go
index f3f2432b..d3cc46bc 100644
--- a/internal/route/repo/setting.go
+++ b/internal/route/repo/setting.go
@@ -14,12 +14,12 @@ import (
"github.com/unknwon/com"
log "unknwon.dev/clog/v2"
+ "gogs.io/gogs/internal/conf"
"gogs.io/gogs/internal/context"
"gogs.io/gogs/internal/db"
"gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/internal/form"
"gogs.io/gogs/internal/mailer"
- "gogs.io/gogs/internal/setting"
"gogs.io/gogs/internal/tool"
)
@@ -196,7 +196,7 @@ func SettingsPost(c *context.Context, f form.RepoSetting) {
}
log.Trace("Repository converted from mirror to regular: %s/%s", c.Repo.Owner.Name, repo.Name)
c.Flash.Success(c.Tr("repo.settings.convert_succeed"))
- c.Redirect(setting.AppSubURL + "/" + c.Repo.Owner.Name + "/" + repo.Name)
+ c.Redirect(conf.Server.Subpath + "/" + c.Repo.Owner.Name + "/" + repo.Name)
case "transfer":
if !c.Repo.IsOwner() {
@@ -235,7 +235,7 @@ func SettingsPost(c *context.Context, f form.RepoSetting) {
}
log.Trace("Repository transfered: %s/%s -> %s", c.Repo.Owner.Name, repo.Name, newOwner)
c.Flash.Success(c.Tr("repo.settings.transfer_succeed"))
- c.Redirect(setting.AppSubURL + "/" + newOwner + "/" + repo.Name)
+ c.Redirect(conf.Server.Subpath + "/" + newOwner + "/" + repo.Name)
case "delete":
if !c.Repo.IsOwner() {
@@ -371,7 +371,7 @@ func SettingsCollaboration(c *context.Context) {
func SettingsCollaborationPost(c *context.Context) {
name := strings.ToLower(c.Query("collaborator"))
if len(name) == 0 || c.Repo.Owner.LowerName == name {
- c.Redirect(setting.AppSubURL + c.Req.URL.Path)
+ c.Redirect(conf.Server.Subpath + c.Req.URL.Path)
return
}
@@ -379,7 +379,7 @@ func SettingsCollaborationPost(c *context.Context) {
if err != nil {
if errors.IsUserNotExist(err) {
c.Flash.Error(c.Tr("form.user_not_exist"))
- c.Redirect(setting.AppSubURL + c.Req.URL.Path)
+ c.Redirect(conf.Server.Subpath + c.Req.URL.Path)
} else {
c.Handle(500, "GetUserByName", err)
}
@@ -389,7 +389,7 @@ func SettingsCollaborationPost(c *context.Context) {
// Organization is not allowed to be added as a collaborator
if u.IsOrganization() {
c.Flash.Error(c.Tr("repo.settings.org_not_allowed_to_be_collaborator"))
- c.Redirect(setting.AppSubURL + c.Req.URL.Path)
+ c.Redirect(conf.Server.Subpath + c.Req.URL.Path)
return
}
@@ -398,12 +398,12 @@ func SettingsCollaborationPost(c *context.Context) {
return
}
- if setting.Service.EnableNotifyMail {
+ if conf.Service.EnableNotifyMail {
mailer.SendCollaboratorMail(db.NewMailerUser(u), db.NewMailerUser(c.User), db.NewMailerRepo(c.Repo.Repository))
}
c.Flash.Success(c.Tr("repo.settings.add_collaborator_success"))
- c.Redirect(setting.AppSubURL + c.Req.URL.Path)
+ c.Redirect(conf.Server.Subpath + c.Req.URL.Path)
}
func ChangeCollaborationAccessMode(c *context.Context) {
diff --git a/internal/route/repo/view.go b/internal/route/repo/view.go
index b03a2cc3..f493f190 100644
--- a/internal/route/repo/view.go
+++ b/internal/route/repo/view.go
@@ -20,7 +20,7 @@ import (
"gogs.io/gogs/internal/context"
"gogs.io/gogs/internal/db"
"gogs.io/gogs/internal/markup"
- "gogs.io/gogs/internal/setting"
+ "gogs.io/gogs/internal/conf"
"gogs.io/gogs/internal/template"
"gogs.io/gogs/internal/template/highlight"
"gogs.io/gogs/internal/tool"
@@ -47,7 +47,7 @@ func renderDirectory(c *context.Context, treeLink string) {
}
entries.Sort()
- c.Data["Files"], err = entries.GetCommitsInfoWithCustomConcurrency(c.Repo.Commit, c.Repo.TreePath, setting.Repository.CommitsFetchConcurrency)
+ c.Data["Files"], err = entries.GetCommitsInfoWithCustomConcurrency(c.Repo.Commit, c.Repo.TreePath, conf.Repository.CommitsFetchConcurrency)
if err != nil {
c.ServerError("GetCommitsInfoWithCustomConcurrency", err)
return
@@ -118,7 +118,7 @@ func renderDirectory(c *context.Context, treeLink string) {
if c.Repo.CanEnableEditor() {
c.Data["CanAddFile"] = true
- c.Data["CanUploadFile"] = setting.Repository.Upload.Enabled
+ c.Data["CanUploadFile"] = conf.Repository.Upload.Enabled
}
}
@@ -152,7 +152,7 @@ func renderFile(c *context.Context, entry *git.TreeEntry, treeLink, rawLink stri
canEnableEditor := c.Repo.CanEnableEditor()
switch {
case isTextFile:
- if blob.Size() >= setting.UI.MaxDisplayFileSize {
+ if blob.Size() >= conf.UI.MaxDisplayFileSize {
c.Data["IsFileTooLarge"] = true
break
}
diff --git a/internal/route/repo/webhook.go b/internal/route/repo/webhook.go
index 2983cbda..8931a056 100644
--- a/internal/route/repo/webhook.go
+++ b/internal/route/repo/webhook.go
@@ -18,7 +18,7 @@ import (
"gogs.io/gogs/internal/db"
"gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/internal/form"
- "gogs.io/gogs/internal/setting"
+ "gogs.io/gogs/internal/conf"
)
const (
@@ -32,7 +32,7 @@ func Webhooks(c *context.Context) {
c.Data["PageIsSettingsHooks"] = true
c.Data["BaseLink"] = c.Repo.RepoLink
c.Data["Description"] = c.Tr("repo.settings.hooks_desc", "https://github.com/gogs/docs-api/blob/master/Repositories/Webhooks.md")
- c.Data["Types"] = setting.Webhook.Types
+ c.Data["Types"] = conf.Webhook.Types
ws, err := db.GetWebhooksByRepoID(c.Repo.Repository.ID)
if err != nil {
@@ -76,7 +76,7 @@ func getOrgRepoCtx(c *context.Context) (*OrgRepoCtx, error) {
func checkHookType(c *context.Context) string {
hookType := strings.ToLower(c.Params(":type"))
- if !com.IsSliceContainsStr(setting.Webhook.Types, hookType) {
+ if !com.IsSliceContainsStr(conf.Webhook.Types, hookType) {
c.Handle(404, "checkHookType", nil)
return ""
}