From 920c0bde2da8b5c7e518b090fde654071715b7d1 Mon Sep 17 00:00:00 2001
From: Kyle D
Date: Wed, 13 Jan 2021 08:53:17 -0700
Subject: [PATCH 0001/1137] Kd/add bountysource (#14323)
* Add bountysource to Sponsors link
* Add badge to readme
---
.github/FUNDING.yml | 1 +
README.md | 3 +++
README_ZH.md | 3 +++
3 files changed, 7 insertions(+)
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
index 1447a6ea3..624a2d97d 100644
--- a/.github/FUNDING.yml
+++ b/.github/FUNDING.yml
@@ -1 +1,2 @@
open_collective: gitea
+custom: https://www.bountysource.com/teams/gitea
diff --git a/README.md b/README.md
index 8fd3f5f60..23ed06dbe 100644
--- a/README.md
+++ b/README.md
@@ -42,6 +42,9 @@
+
+
+
diff --git a/README_ZH.md b/README_ZH.md
index cb3c7d64b..037f27dc9 100644
--- a/README_ZH.md
+++ b/README_ZH.md
@@ -42,6 +42,9 @@
+
+
+
From 648d85d426044686c8fd03591401c1c9d21ed3fa Mon Sep 17 00:00:00 2001
From: GiteaBot
Date: Wed, 13 Jan 2021 15:54:47 +0000
Subject: [PATCH 0002/1137] [skip ci] Updated translations via Crowdin
---
options/locale/locale_zh-TW.ini | 2 ++
1 file changed, 2 insertions(+)
diff --git a/options/locale/locale_zh-TW.ini b/options/locale/locale_zh-TW.ini
index 4864698ee..b1eb4eaab 100644
--- a/options/locale/locale_zh-TW.ini
+++ b/options/locale/locale_zh-TW.ini
@@ -821,6 +821,8 @@ tag=標籤
released_this=發佈了此版本
file_raw=原始文件
file_history=歷史記錄
+file_view_source=檢視原始碼
+file_view_rendered=檢視渲染圖
file_view_raw=查看原始文件
file_permalink=永久連結
file_too_large=檔案太大,無法顯示。
From 954aeefb05ee48a8c4ff6006ea449f313a6b9848 Mon Sep 17 00:00:00 2001
From: techknowlogick
Date: Wed, 13 Jan 2021 10:55:52 -0500
Subject: [PATCH 0003/1137] Update Link
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 23ed06dbe..ea0d83c90 100644
--- a/README.md
+++ b/README.md
@@ -42,7 +42,7 @@
-
+
From edbc5c86dfda07a0eada0acd7461a610fee00ae3 Mon Sep 17 00:00:00 2001
From: Kyungmin Bae
Date: Thu, 14 Jan 2021 05:30:46 +0900
Subject: [PATCH 0004/1137] Use Request.URL.RequestURI() for fcgi (#14312)
(#14314)
---
custom/conf/app.example.ini | 2 +-
routers/routes/chi.go | 12 ++++++------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini
index 045b4cfed..e68727eb8 100644
--- a/custom/conf/app.example.ini
+++ b/custom/conf/app.example.ini
@@ -867,7 +867,7 @@ MACARON = file
ROUTER_LOG_LEVEL = Info
ROUTER = console
ENABLE_ACCESS_LOG = false
-ACCESS_LOG_TEMPLATE = {{.Ctx.RemoteAddr}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}\" \"{{.Ctx.Req.UserAgent}}"
+ACCESS_LOG_TEMPLATE = {{.Ctx.RemoteAddr}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.URL.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}\" \"{{.Ctx.Req.UserAgent}}"
ACCESS = file
; Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "Trace"
LEVEL = Info
diff --git a/routers/routes/chi.go b/routers/routes/chi.go
index 6e609fc2f..16fd6ea90 100644
--- a/routers/routes/chi.go
+++ b/routers/routes/chi.go
@@ -86,14 +86,14 @@ func LoggerHandler(level log.Level) func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
start := time.Now()
- _ = log.GetLogger("router").Log(0, level, "Started %s %s for %s", log.ColoredMethod(req.Method), req.RequestURI, req.RemoteAddr)
+ _ = log.GetLogger("router").Log(0, level, "Started %s %s for %s", log.ColoredMethod(req.Method), req.URL.RequestURI(), req.RemoteAddr)
next.ServeHTTP(w, req)
ww := middleware.NewWrapResponseWriter(w, req.ProtoMajor)
status := ww.Status()
- _ = log.GetLogger("router").Log(0, level, "Completed %s %s %v %s in %v", log.ColoredMethod(req.Method), req.RequestURI, log.ColoredStatus(status), log.ColoredStatus(status, http.StatusText(status)), log.ColoredTime(time.Since(start)))
+ _ = log.GetLogger("router").Log(0, level, "Completed %s %s %v %s in %v", log.ColoredMethod(req.Method), req.URL.RequestURI(), log.ColoredStatus(status), log.ColoredStatus(status, http.StatusText(status)), log.ColoredTime(time.Since(start)))
})
}
}
@@ -107,12 +107,12 @@ func storageHandler(storageSetting setting.Storage, prefix string, objStore stor
return
}
- if !strings.HasPrefix(req.RequestURI, "/"+prefix) {
+ if !strings.HasPrefix(req.URL.RequestURI(), "/"+prefix) {
next.ServeHTTP(w, req)
return
}
- rPath := strings.TrimPrefix(req.RequestURI, "/"+prefix)
+ rPath := strings.TrimPrefix(req.URL.RequestURI(), "/"+prefix)
u, err := objStore.URL(rPath, path.Base(rPath))
if err != nil {
if os.IsNotExist(err) || errors.Is(err, os.ErrNotExist) {
@@ -139,12 +139,12 @@ func storageHandler(storageSetting setting.Storage, prefix string, objStore stor
return
}
- if !strings.HasPrefix(req.RequestURI, "/"+prefix) {
+ if !strings.HasPrefix(req.URL.RequestURI(), "/"+prefix) {
next.ServeHTTP(w, req)
return
}
- rPath := strings.TrimPrefix(req.RequestURI, "/"+prefix)
+ rPath := strings.TrimPrefix(req.URL.RequestURI(), "/"+prefix)
rPath = strings.TrimPrefix(rPath, "/")
fi, err := objStore.Stat(rPath)
From f76c30094f086162d09926a95e9a75c91177a674 Mon Sep 17 00:00:00 2001
From: Lunny Xiao
Date: Thu, 14 Jan 2021 23:35:10 +0800
Subject: [PATCH 0005/1137] Fix typo (#14332)
---
modules/auth/sso/sspi_windows.go | 2 +-
routers/routes/recovery.go | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/modules/auth/sso/sspi_windows.go b/modules/auth/sso/sspi_windows.go
index 44dfa81aa..46309c27f 100644
--- a/modules/auth/sso/sspi_windows.go
+++ b/modules/auth/sso/sspi_windows.go
@@ -95,7 +95,7 @@ func (s *SSPI) VerifyAuthData(req *http.Request, w http.ResponseWriter, store Da
// to login with another authentication method if SSPI authentication
// fails
store.GetData()["Flash"] = map[string]string{
- "ErrMsg": err.Error(),
+ "ErrorMsg": err.Error(),
}
store.GetData()["EnableOpenIDSignIn"] = setting.Service.EnableOpenIDSignIn
store.GetData()["EnableSSPI"] = true
diff --git a/routers/routes/recovery.go b/routers/routes/recovery.go
index f392d1d55..7f33fee0f 100644
--- a/routers/routes/recovery.go
+++ b/routers/routes/recovery.go
@@ -95,7 +95,7 @@ func Recovery() func(next http.Handler) http.Handler {
w.Header().Set(`X-Frame-Options`, `SAMEORIGIN`)
if setting.RunMode != "prod" {
- store.Data["ErrMsg"] = combinedErr
+ store.Data["ErrorMsg"] = combinedErr
}
err = rnd.HTML(w, 500, "status/500", templates.BaseVars().Merge(store.Data))
if err != nil {
From 60a3297a33b2209ae7acf6fd84afd62e095e01aa Mon Sep 17 00:00:00 2001
From: Lunny Xiao
Date: Fri, 15 Jan 2021 04:27:22 +0800
Subject: [PATCH 0006/1137] Use ServerError provided by Context (#14333)
... instead of InternalServerError by macaron
---
routers/admin/users.go | 8 ++++----
routers/repo/issue.go | 2 +-
routers/repo/projects.go | 4 ++--
routers/repo/pull.go | 4 ++--
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/routers/admin/users.go b/routers/admin/users.go
index 9fe5c3ef7..74fce9a10 100644
--- a/routers/admin/users.go
+++ b/routers/admin/users.go
@@ -188,7 +188,7 @@ func prepareUserInfo(ctx *context.Context) *models.User {
_, err = models.GetTwoFactorByUID(u.ID)
if err != nil {
if !models.IsErrTwoFactorNotEnrolled(err) {
- ctx.InternalServerError(err)
+ ctx.ServerError("IsErrTwoFactorNotEnrolled", err)
return nil
}
ctx.Data["TwoFactorEnabled"] = false
@@ -268,7 +268,7 @@ func EditUserPost(ctx *context.Context, form auth.AdminEditUserForm) {
return
}
if err = u.SetPassword(form.Password); err != nil {
- ctx.InternalServerError(err)
+ ctx.ServerError("SetPassword", err)
return
}
}
@@ -285,12 +285,12 @@ func EditUserPost(ctx *context.Context, form auth.AdminEditUserForm) {
if form.Reset2FA {
tf, err := models.GetTwoFactorByUID(u.ID)
if err != nil && !models.IsErrTwoFactorNotEnrolled(err) {
- ctx.InternalServerError(err)
+ ctx.ServerError("GetTwoFactorByUID", err)
return
}
if err = models.DeleteTwoFactorByID(tf.ID, u.ID); err != nil {
- ctx.InternalServerError(err)
+ ctx.ServerError("DeleteTwoFactorByID", err)
return
}
}
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 1d8d9c036..478baf8d8 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -1117,7 +1117,7 @@ func ViewIssue(ctx *context.Context) {
iw.IssueID = issue.ID
iw.IsWatching, err = models.CheckIssueWatch(ctx.User, issue)
if err != nil {
- ctx.InternalServerError(err)
+ ctx.ServerError("CheckIssueWatch", err)
return
}
}
diff --git a/routers/repo/projects.go b/routers/repo/projects.go
index 07327df9e..08746aad9 100644
--- a/routers/repo/projects.go
+++ b/routers/repo/projects.go
@@ -355,7 +355,7 @@ func DeleteProjectBoard(ctx *context.Context) {
pb, err := models.GetProjectBoard(ctx.ParamsInt64(":boardID"))
if err != nil {
- ctx.InternalServerError(err)
+ ctx.ServerError("GetProjectBoard", err)
return
}
if pb.ProjectID != ctx.ParamsInt64(":id") {
@@ -445,7 +445,7 @@ func EditProjectBoardTitle(ctx *context.Context, form auth.EditProjectBoardTitle
board, err := models.GetProjectBoard(ctx.ParamsInt64(":boardID"))
if err != nil {
- ctx.InternalServerError(err)
+ ctx.ServerError("GetProjectBoard", err)
return
}
if board.ProjectID != ctx.ParamsInt64(":id") {
diff --git a/routers/repo/pull.go b/routers/repo/pull.go
index 1594e9a9c..01c6efaa1 100644
--- a/routers/repo/pull.go
+++ b/routers/repo/pull.go
@@ -713,11 +713,11 @@ func UpdatePullRequest(ctx *context.Context) {
}
if err := issue.PullRequest.LoadBaseRepo(); err != nil {
- ctx.InternalServerError(err)
+ ctx.ServerError("LoadBaseRepo", err)
return
}
if err := issue.PullRequest.LoadHeadRepo(); err != nil {
- ctx.InternalServerError(err)
+ ctx.ServerError("LoadHeadRepo", err)
return
}
From 84b147c7f0c2575723d3471783cb24078232fe7a Mon Sep 17 00:00:00 2001
From: Lunny Xiao
Date: Fri, 15 Jan 2021 05:17:03 +0800
Subject: [PATCH 0007/1137] Use IsProd instead of testing if it's equal.
(#14336)
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath
---
cmd/serv.go | 4 ++--
models/models.go | 4 ++--
modules/auth/sso/sspi_windows.go | 2 +-
modules/httpcache/httpcache.go | 2 +-
modules/setting/setting.go | 6 +++++-
routers/init.go | 2 +-
routers/routes/recovery.go | 11 +++++------
7 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/cmd/serv.go b/cmd/serv.go
index fb1e58113..1e66cb511 100644
--- a/cmd/serv.go
+++ b/cmd/serv.go
@@ -58,7 +58,7 @@ func setup(logPath string, debug bool) {
}
setting.NewContext()
if debug {
- setting.ProdMode = false
+ setting.RunMode = "dev"
}
}
@@ -76,7 +76,7 @@ func fail(userMessage, logMessage string, args ...interface{}) {
fmt.Fprintln(os.Stderr, "Gitea:", userMessage)
if len(logMessage) > 0 {
- if !setting.ProdMode {
+ if !setting.IsProd() {
fmt.Fprintf(os.Stderr, logMessage+"\n", args...)
}
}
diff --git a/models/models.go b/models/models.go
index f12a4e8b3..2ace1ea6d 100644
--- a/models/models.go
+++ b/models/models.go
@@ -175,8 +175,8 @@ func NewTestEngine() (err error) {
}
x.SetMapper(names.GonicMapper{})
- x.SetLogger(NewXORMLogger(!setting.ProdMode))
- x.ShowSQL(!setting.ProdMode)
+ x.SetLogger(NewXORMLogger(!setting.IsProd()))
+ x.ShowSQL(!setting.IsProd())
return x.StoreEngine("InnoDB").Sync2(tables...)
}
diff --git a/modules/auth/sso/sspi_windows.go b/modules/auth/sso/sspi_windows.go
index 46309c27f..448336c07 100644
--- a/modules/auth/sso/sspi_windows.go
+++ b/modules/auth/sso/sspi_windows.go
@@ -56,7 +56,7 @@ func (s *SSPI) Init() error {
Funcs: templates.NewFuncMap(),
Asset: templates.GetAsset,
AssetNames: templates.GetAssetNames,
- IsDevelopment: setting.RunMode != "prod",
+ IsDevelopment: !setting.IsProd(),
})
return nil
}
diff --git a/modules/httpcache/httpcache.go b/modules/httpcache/httpcache.go
index c4134f8e1..cf35cef12 100644
--- a/modules/httpcache/httpcache.go
+++ b/modules/httpcache/httpcache.go
@@ -17,7 +17,7 @@ import (
// GetCacheControl returns a suitable "Cache-Control" header value
func GetCacheControl() string {
- if setting.RunMode == "dev" {
+ if !setting.IsProd() {
return "no-store"
}
return "private, max-age=" + strconv.FormatInt(int64(setting.StaticCacheTime.Seconds()), 10)
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index 8ab4508ce..c162c751c 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -376,7 +376,6 @@ var (
CustomConf string
PIDFile = "/run/gitea.pid"
WritePIDFile bool
- ProdMode bool
RunMode string
RunUser string
IsWindows bool
@@ -388,6 +387,11 @@ var (
UILocation = time.Local
)
+// IsProd if it's a production mode
+func IsProd() bool {
+ return strings.EqualFold(RunMode, "prod")
+}
+
func getAppPath() (string, error) {
var appPath string
var err error
diff --git a/routers/init.go b/routers/init.go
index ff2ddcc0b..79e2f9130 100644
--- a/routers/init.go
+++ b/routers/init.go
@@ -50,7 +50,7 @@ func checkRunMode() {
default:
macaron.Env = macaron.PROD
macaron.ColorLog = false
- setting.ProdMode = true
+ git.Debug = false
}
log.Info("Run Mode: %s", strings.Title(macaron.Env))
}
diff --git a/routers/routes/recovery.go b/routers/routes/recovery.go
index 7f33fee0f..cfe1a4114 100644
--- a/routers/routes/recovery.go
+++ b/routers/routes/recovery.go
@@ -29,7 +29,6 @@ func (d *dataStore) GetData() map[string]interface{} {
// Although similar to macaron.Recovery() the main difference is that this error will be created
// with the gitea 500 page.
func Recovery() func(next http.Handler) http.Handler {
- var isDevelopment = setting.RunMode != "prod"
return func(next http.Handler) http.Handler {
rnd := render.New(render.Options{
Extensions: []string{".tmpl"},
@@ -37,7 +36,7 @@ func Recovery() func(next http.Handler) http.Handler {
Funcs: templates.NewFuncMap(),
Asset: templates.GetAsset,
AssetNames: templates.GetAssetNames,
- IsDevelopment: isDevelopment,
+ IsDevelopment: !setting.IsProd(),
})
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
@@ -50,10 +49,10 @@ func Recovery() func(next http.Handler) http.Handler {
if err := recover(); err != nil {
combinedErr := fmt.Sprintf("PANIC: %v\n%s", err, string(log.Stack(2)))
log.Error(combinedErr)
- if isDevelopment {
- http.Error(w, combinedErr, 500)
- } else {
+ if setting.IsProd() {
http.Error(w, http.StatusText(500), 500)
+ } else {
+ http.Error(w, combinedErr, 500)
}
}
}()
@@ -94,7 +93,7 @@ func Recovery() func(next http.Handler) http.Handler {
w.Header().Set(`X-Frame-Options`, `SAMEORIGIN`)
- if setting.RunMode != "prod" {
+ if !setting.IsProd() {
store.Data["ErrorMsg"] = combinedErr
}
err = rnd.HTML(w, 500, "status/500", templates.BaseVars().Merge(store.Data))
From 6eee9f0f4e56e620b2eacfc9c2b59c6448308290 Mon Sep 17 00:00:00 2001
From: Lauris BH
Date: Fri, 15 Jan 2021 01:24:03 +0200
Subject: [PATCH 0008/1137] Merge default and system webhooks under one menu
(#14244)
---
models/webhook.go | 20 +-----
options/locale/locale_en-US.ini | 13 ++--
routers/admin/hooks.go | 54 ++++++++--------
routers/org/setting.go | 1 +
routers/repo/webhook.go | 30 +++++----
routers/routes/macaron.go | 25 ++++----
templates/admin/hook_new.tmpl | 10 ++-
templates/admin/hooks.tmpl | 7 ++-
templates/admin/navbar.tmpl | 5 +-
.../repo/settings/webhook/base_list.tmpl | 60 ++++++++++++++++++
templates/repo/settings/webhook/list.tmpl | 62 +------------------
templates/repo/settings/webhook/settings.tmpl | 2 +-
12 files changed, 148 insertions(+), 141 deletions(-)
create mode 100644 templates/repo/settings/webhook/base_list.tmpl
diff --git a/models/webhook.go b/models/webhook.go
index e0a75843d..5174bb612 100644
--- a/models/webhook.go
+++ b/models/webhook.go
@@ -400,20 +400,6 @@ func GetWebhooksByOrgID(orgID int64, listOptions ListOptions) ([]*Webhook, error
return ws, sess.Find(&ws, &Webhook{OrgID: orgID})
}
-// GetDefaultWebhook returns admin-default webhook by given ID.
-func GetDefaultWebhook(id int64) (*Webhook, error) {
- webhook := &Webhook{ID: id}
- has, err := x.
- Where("repo_id=? AND org_id=? AND is_system_webhook=?", 0, 0, false).
- Get(webhook)
- if err != nil {
- return nil, err
- } else if !has {
- return nil, ErrWebhookNotExist{id}
- }
- return webhook, nil
-}
-
// GetDefaultWebhooks returns all admin-default webhooks.
func GetDefaultWebhooks() ([]*Webhook, error) {
return getDefaultWebhooks(x)
@@ -426,11 +412,11 @@ func getDefaultWebhooks(e Engine) ([]*Webhook, error) {
Find(&webhooks)
}
-// GetSystemWebhook returns admin system webhook by given ID.
-func GetSystemWebhook(id int64) (*Webhook, error) {
+// GetSystemOrDefaultWebhook returns admin system or default webhook by given ID.
+func GetSystemOrDefaultWebhook(id int64) (*Webhook, error) {
webhook := &Webhook{ID: id}
has, err := x.
- Where("repo_id=? AND org_id=? AND is_system_webhook=?", 0, 0, true).
+ Where("repo_id=? AND org_id=?", 0, 0).
Get(webhook)
if err != nil {
return nil, err
diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini
index 48a43aa90..4264d260d 100644
--- a/options/locale/locale_en-US.ini
+++ b/options/locale/locale_en-US.ini
@@ -2001,8 +2001,7 @@ dashboard = Dashboard
users = User Accounts
organizations = Organizations
repositories = Repositories
-hooks = Default Webhooks
-systemhooks = System Webhooks
+hooks = Webhooks
authentication = Authentication Sources
emails = User Emails
config = Configuration
@@ -2152,11 +2151,13 @@ repos.forks = Forks
repos.issues = Issues
repos.size = Size
-hooks.desc = Webhooks automatically make HTTP POST requests to a server when certain Gitea events trigger. Webhooks defined here are defaults and will be copied into all new repositories. Read more in the webhooks guide.
-hooks.add_webhook = Add Default Webhook
-hooks.update_webhook = Update Default Webhook
+defaulthooks = Default Webhooks
+defaulthooks.desc = Webhooks automatically make HTTP POST requests to a server when certain Gitea events trigger. Webhooks defined here are defaults and will be copied into all new repositories. Read more in the webhooks guide.
+defaulthooks.add_webhook = Add Default Webhook
+defaulthooks.update_webhook = Update Default Webhook
-systemhooks.desc = Webhooks automatically make HTTP POST requests to a server when certain Gitea events trigger. Webhooks defined will act on all repositories on the system, so please consider any performance implications this may have. Read more in the webhooks guide.
+systemhooks = System Webhooks
+systemhooks.desc = Webhooks automatically make HTTP POST requests to a server when certain Gitea events trigger. Webhooks defined here will act on all repositories on the system, so please consider any performance implications this may have. Read more in the webhooks guide.
systemhooks.add_webhook = Add System Webhook
systemhooks.update_webhook = Update System Webhook
diff --git a/routers/admin/hooks.go b/routers/admin/hooks.go
index 4697c4d93..e233e8ac0 100644
--- a/routers/admin/hooks.go
+++ b/routers/admin/hooks.go
@@ -18,30 +18,41 @@ const (
// DefaultOrSystemWebhooks renders both admin default and system webhook list pages
func DefaultOrSystemWebhooks(ctx *context.Context) {
- var ws []*models.Webhook
var err error
- // Are we looking at default webhooks?
- if ctx.Params(":configType") == "hooks" {
- ctx.Data["Title"] = ctx.Tr("admin.hooks")
- ctx.Data["Description"] = ctx.Tr("admin.hooks.desc")
- ctx.Data["PageIsAdminHooks"] = true
- ctx.Data["BaseLink"] = setting.AppSubURL + "/admin/hooks"
- ws, err = models.GetDefaultWebhooks()
- } else {
- ctx.Data["Title"] = ctx.Tr("admin.systemhooks")
- ctx.Data["Description"] = ctx.Tr("admin.systemhooks.desc")
- ctx.Data["PageIsAdminSystemHooks"] = true
- ctx.Data["BaseLink"] = setting.AppSubURL + "/admin/system-hooks"
- ws, err = models.GetSystemWebhooks()
+ ctx.Data["PageIsAdminSystemHooks"] = true
+ ctx.Data["PageIsAdminDefaultHooks"] = true
+
+ def := make(map[string]interface{}, len(ctx.Data))
+ sys := make(map[string]interface{}, len(ctx.Data))
+ for k, v := range ctx.Data {
+ def[k] = v
+ sys[k] = v
}
+ sys["Title"] = ctx.Tr("admin.systemhooks")
+ sys["Description"] = ctx.Tr("admin.systemhooks.desc")
+ sys["Webhooks"], err = models.GetSystemWebhooks()
+ sys["BaseLink"] = setting.AppSubURL + "/admin/hooks"
+ sys["BaseLinkNew"] = setting.AppSubURL + "/admin/system-hooks"
if err != nil {
ctx.ServerError("GetWebhooksAdmin", err)
return
}
- ctx.Data["Webhooks"] = ws
+ def["Title"] = ctx.Tr("admin.defaulthooks")
+ def["Description"] = ctx.Tr("admin.defaulthooks.desc")
+ def["Webhooks"], err = models.GetDefaultWebhooks()
+ def["BaseLink"] = setting.AppSubURL + "/admin/hooks"
+ def["BaseLinkNew"] = setting.AppSubURL + "/admin/default-hooks"
+ if err != nil {
+ ctx.ServerError("GetWebhooksAdmin", err)
+ return
+ }
+
+ ctx.Data["DefaultWebhooks"] = def
+ ctx.Data["SystemWebhooks"] = sys
+
ctx.HTML(200, tplAdminHooks)
}
@@ -53,14 +64,7 @@ func DeleteDefaultOrSystemWebhook(ctx *context.Context) {
ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success"))
}
- // Are we looking at default webhooks?
- if ctx.Params(":configType") == "hooks" {
- ctx.JSON(200, map[string]interface{}{
- "redirect": setting.AppSubURL + "/admin/hooks",
- })
- } else {
- ctx.JSON(200, map[string]interface{}{
- "redirect": setting.AppSubURL + "/admin/system-hooks",
- })
- }
+ ctx.JSON(200, map[string]interface{}{
+ "redirect": setting.AppSubURL + "/admin/hooks",
+ })
}
diff --git a/routers/org/setting.go b/routers/org/setting.go
index 454714c7e..05075ca82 100644
--- a/routers/org/setting.go
+++ b/routers/org/setting.go
@@ -173,6 +173,7 @@ func Webhooks(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("org.settings")
ctx.Data["PageIsSettingsHooks"] = true
ctx.Data["BaseLink"] = ctx.Org.OrgLink + "/settings/hooks"
+ ctx.Data["BaseLinkNew"] = ctx.Org.OrgLink + "/settings/hooks"
ctx.Data["Description"] = ctx.Tr("org.settings.hooks_desc")
ws, err := models.GetWebhooksByOrgID(ctx.Org.Organization.ID, models.ListOptions{})
diff --git a/routers/repo/webhook.go b/routers/repo/webhook.go
index 0c3fd1267..5d7074b33 100644
--- a/routers/repo/webhook.go
+++ b/routers/repo/webhook.go
@@ -36,6 +36,7 @@ func Webhooks(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.settings.hooks")
ctx.Data["PageIsSettingsHooks"] = true
ctx.Data["BaseLink"] = ctx.Repo.RepoLink + "/settings/hooks"
+ ctx.Data["BaseLinkNew"] = ctx.Repo.RepoLink + "/settings/hooks"
ctx.Data["Description"] = ctx.Tr("repo.settings.hooks_desc", "https://docs.gitea.io/en-us/webhooks/")
ws, err := models.GetWebhooksByRepoID(ctx.Repo.Repository.ID, models.ListOptions{})
@@ -54,6 +55,7 @@ type orgRepoCtx struct {
IsAdmin bool
IsSystemWebhook bool
Link string
+ LinkNew string
NewTemplate base.TplName
}
@@ -63,6 +65,7 @@ func getOrgRepoCtx(ctx *context.Context) (*orgRepoCtx, error) {
return &orgRepoCtx{
RepoID: ctx.Repo.Repository.ID,
Link: path.Join(ctx.Repo.RepoLink, "settings/hooks"),
+ LinkNew: path.Join(ctx.Repo.RepoLink, "settings/hooks"),
NewTemplate: tplHookNew,
}, nil
}
@@ -71,16 +74,18 @@ func getOrgRepoCtx(ctx *context.Context) (*orgRepoCtx, error) {
return &orgRepoCtx{
OrgID: ctx.Org.Organization.ID,
Link: path.Join(ctx.Org.OrgLink, "settings/hooks"),
+ LinkNew: path.Join(ctx.Org.OrgLink, "settings/hooks"),
NewTemplate: tplOrgHookNew,
}, nil
}
if ctx.User.IsAdmin {
// Are we looking at default webhooks?
- if ctx.Params(":configType") == "hooks" {
+ if ctx.Params(":configType") == "default-hooks" {
return &orgRepoCtx{
IsAdmin: true,
Link: path.Join(setting.AppSubURL, "/admin/hooks"),
+ LinkNew: path.Join(setting.AppSubURL, "/admin/default-hooks"),
NewTemplate: tplAdminHookNew,
}, nil
}
@@ -89,7 +94,8 @@ func getOrgRepoCtx(ctx *context.Context) (*orgRepoCtx, error) {
return &orgRepoCtx{
IsAdmin: true,
IsSystemWebhook: true,
- Link: path.Join(setting.AppSubURL, "/admin/system-hooks"),
+ Link: path.Join(setting.AppSubURL, "/admin/hooks"),
+ LinkNew: path.Join(setting.AppSubURL, "/admin/system-hooks"),
NewTemplate: tplAdminHookNew,
}, nil
}
@@ -121,8 +127,8 @@ func WebhooksNew(ctx *context.Context) {
ctx.Data["PageIsAdminSystemHooks"] = true
ctx.Data["PageIsAdminSystemHooksNew"] = true
} else if orCtx.IsAdmin {
- ctx.Data["PageIsAdminHooks"] = true
- ctx.Data["PageIsAdminHooksNew"] = true
+ ctx.Data["PageIsAdminDefaultHooks"] = true
+ ctx.Data["PageIsAdminDefaultHooksNew"] = true
} else {
ctx.Data["PageIsSettingsHooks"] = true
ctx.Data["PageIsSettingsHooksNew"] = true
@@ -139,7 +145,7 @@ func WebhooksNew(ctx *context.Context) {
"IconURL": setting.AppURL + "img/favicon.png",
}
}
- ctx.Data["BaseLink"] = orCtx.Link
+ ctx.Data["BaseLink"] = orCtx.LinkNew
ctx.HTML(200, orCtx.NewTemplate)
}
@@ -187,7 +193,7 @@ func GiteaHooksNewPost(ctx *context.Context, form auth.NewWebhookForm) {
ctx.ServerError("getOrgRepoCtx", err)
return
}
- ctx.Data["BaseLink"] = orCtx.Link
+ ctx.Data["BaseLink"] = orCtx.LinkNew
if ctx.HasError() {
ctx.HTML(200, orCtx.NewTemplate)
@@ -241,7 +247,7 @@ func newGogsWebhookPost(ctx *context.Context, form auth.NewGogshookForm, kind mo
ctx.ServerError("getOrgRepoCtx", err)
return
}
- ctx.Data["BaseLink"] = orCtx.Link
+ ctx.Data["BaseLink"] = orCtx.LinkNew
if ctx.HasError() {
ctx.HTML(200, orCtx.NewTemplate)
@@ -537,7 +543,7 @@ func SlackHooksNewPost(ctx *context.Context, form auth.NewSlackHookForm) {
if form.HasInvalidChannel() {
ctx.Flash.Error(ctx.Tr("repo.settings.add_webhook.invalid_channel_name"))
- ctx.Redirect(orCtx.Link + "/slack/new")
+ ctx.Redirect(orCtx.LinkNew + "/slack/new")
return
}
@@ -632,12 +638,10 @@ func checkWebhook(ctx *context.Context) (*orgRepoCtx, *models.Webhook) {
w, err = models.GetWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
} else if orCtx.OrgID > 0 {
w, err = models.GetWebhookByOrgID(ctx.Org.Organization.ID, ctx.ParamsInt64(":id"))
- } else if orCtx.IsSystemWebhook {
- w, err = models.GetSystemWebhook(ctx.ParamsInt64(":id"))
- } else {
- w, err = models.GetDefaultWebhook(ctx.ParamsInt64(":id"))
+ } else if orCtx.IsAdmin {
+ w, err = models.GetSystemOrDefaultWebhook(ctx.ParamsInt64(":id"))
}
- if err != nil {
+ if err != nil || w == nil {
if models.IsErrWebhookNotExist(err) {
ctx.NotFound("GetWebhookByID", nil)
} else {
diff --git a/routers/routes/macaron.go b/routers/routes/macaron.go
index 66c39b7f8..d331e4ca8 100644
--- a/routers/routes/macaron.go
+++ b/routers/routes/macaron.go
@@ -370,19 +370,9 @@ func RegisterMacaronRoutes(m *macaron.Macaron) {
m.Post("/delete", admin.DeleteRepo)
})
- m.Group("/^:configType(hooks|system-hooks)$", func() {
+ m.Group("/hooks", func() {
m.Get("", admin.DefaultOrSystemWebhooks)
m.Post("/delete", admin.DeleteDefaultOrSystemWebhook)
- m.Get("/:type/new", repo.WebhooksNew)
- m.Post("/gitea/new", bindIgnErr(auth.NewWebhookForm{}), repo.GiteaHooksNewPost)
- m.Post("/gogs/new", bindIgnErr(auth.NewGogshookForm{}), repo.GogsHooksNewPost)
- m.Post("/slack/new", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksNewPost)
- m.Post("/discord/new", bindIgnErr(auth.NewDiscordHookForm{}), repo.DiscordHooksNewPost)
- m.Post("/dingtalk/new", bindIgnErr(auth.NewDingtalkHookForm{}), repo.DingtalkHooksNewPost)
- m.Post("/telegram/new", bindIgnErr(auth.NewTelegramHookForm{}), repo.TelegramHooksNewPost)
- m.Post("/matrix/new", bindIgnErr(auth.NewMatrixHookForm{}), repo.MatrixHooksNewPost)
- m.Post("/msteams/new", bindIgnErr(auth.NewMSTeamsHookForm{}), repo.MSTeamsHooksNewPost)
- m.Post("/feishu/new", bindIgnErr(auth.NewFeishuHookForm{}), repo.FeishuHooksNewPost)
m.Get("/:id", repo.WebHooksEdit)
m.Post("/gitea/:id", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksEditPost)
m.Post("/gogs/:id", bindIgnErr(auth.NewGogshookForm{}), repo.GogsHooksEditPost)
@@ -395,6 +385,19 @@ func RegisterMacaronRoutes(m *macaron.Macaron) {
m.Post("/feishu/:id", bindIgnErr(auth.NewFeishuHookForm{}), repo.FeishuHooksEditPost)
})
+ m.Group("/^:configType(default-hooks|system-hooks)$", func() {
+ m.Get("/:type/new", repo.WebhooksNew)
+ m.Post("/gitea/new", bindIgnErr(auth.NewWebhookForm{}), repo.GiteaHooksNewPost)
+ m.Post("/gogs/new", bindIgnErr(auth.NewGogshookForm{}), repo.GogsHooksNewPost)
+ m.Post("/slack/new", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksNewPost)
+ m.Post("/discord/new", bindIgnErr(auth.NewDiscordHookForm{}), repo.DiscordHooksNewPost)
+ m.Post("/dingtalk/new", bindIgnErr(auth.NewDingtalkHookForm{}), repo.DingtalkHooksNewPost)
+ m.Post("/telegram/new", bindIgnErr(auth.NewTelegramHookForm{}), repo.TelegramHooksNewPost)
+ m.Post("/matrix/new", bindIgnErr(auth.NewMatrixHookForm{}), repo.MatrixHooksNewPost)
+ m.Post("/msteams/new", bindIgnErr(auth.NewMSTeamsHookForm{}), repo.MSTeamsHooksNewPost)
+ m.Post("/feishu/new", bindIgnErr(auth.NewFeishuHookForm{}), repo.FeishuHooksNewPost)
+ })
+
m.Group("/auths", func() {
m.Get("", admin.Authentications)
m.Combo("/new").Get(admin.NewAuthSource).Post(bindIgnErr(auth.AuthenticationForm{}), admin.NewAuthSourcePost)
diff --git a/templates/admin/hook_new.tmpl b/templates/admin/hook_new.tmpl
index c6f02ee20..9b251ec4c 100644
--- a/templates/admin/hook_new.tmpl
+++ b/templates/admin/hook_new.tmpl
@@ -4,10 +4,14 @@
{{template "base/alert" .}}
{{end}}
diff --git a/templates/repo/issue/milestone_issues.tmpl b/templates/repo/issue/milestone_issues.tmpl
index 638134c44..c2c81682f 100644
--- a/templates/repo/issue/milestone_issues.tmpl
+++ b/templates/repo/issue/milestone_issues.tmpl
@@ -88,6 +88,7 @@
{{.i18n.Tr "repo.issues.filter_type.assigned_to_you"}}
{{.i18n.Tr "repo.issues.filter_type.created_by_you"}}
{{.i18n.Tr "repo.issues.filter_type.mentioning_you"}}
+ {{.i18n.Tr "repo.issues.filter_type.review_requested"}}
{{end}}
diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl
index 81ccf4f72..6650c09bb 100644
--- a/templates/swagger/v1_json.tmpl
+++ b/templates/swagger/v1_json.tmpl
@@ -1911,6 +1911,12 @@
"name": "mentioned",
"in": "query"
},
+ {
+ "type": "boolean",
+ "description": "filter pulls requesting your review, default is false",
+ "name": "review_requested",
+ "in": "query"
+ },
{
"type": "integer",
"description": "page number of results to return (1-based)",
diff --git a/templates/user/dashboard/issues.tmpl b/templates/user/dashboard/issues.tmpl
index 62428dce4..dfd0e5d8e 100644
--- a/templates/user/dashboard/issues.tmpl
+++ b/templates/user/dashboard/issues.tmpl
@@ -21,6 +21,12 @@
{{.i18n.Tr "repo.issues.filter_type.mentioning_you"}}
{{CountFmt .IssueStats.MentionCount}}
+ {{if .PageIsPulls}}
+
+ {{.i18n.Tr "repo.issues.filter_type.review_requested"}}
+ {{CountFmt .IssueStats.ReviewRequestedCount}}
+
+ {{end}}
All
From ca63a9d3f1120d8c76eb83ff1fd07e0992a683a8 Mon Sep 17 00:00:00 2001
From: Lauris BH
Date: Sun, 17 Jan 2021 19:29:10 +0200
Subject: [PATCH 0022/1137] Add edit, delete and reaction support to code
review comments on issue page (#14339)
---
routers/repo/issue.go | 19 ++++++
templates/repo/diff/comments.tmpl | 2 +-
.../repo/issue/view_content/comments.tmpl | 63 ++++++++++++++-----
.../repo/issue/view_content/context_menu.tmpl | 6 +-
web_src/less/_repository.less | 31 +++++++++
5 files changed, 101 insertions(+), 20 deletions(-)
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 7b4044ac7..6a532dc12 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -1377,7 +1377,26 @@ func ViewIssue(ctx *context.Context) {
ctx.ServerError("Review.LoadCodeComments", err)
return
}
+ for _, codeComments := range comment.Review.CodeComments {
+ for _, lineComments := range codeComments {
+ for _, c := range lineComments {
+ // Check tag.
+ tag, ok = marked[c.PosterID]
+ if ok {
+ c.ShowTag = tag
+ continue
+ }
+ c.ShowTag, err = commentTag(repo, c.Poster, issue)
+ if err != nil {
+ ctx.ServerError("commentTag", err)
+ return
+ }
+ marked[c.PosterID] = c.ShowTag
+ participants = addParticipant(c.Poster, participants)
+ }
+ }
+ }
if err = comment.LoadResolveDoer(); err != nil {
ctx.ServerError("LoadResolveDoer", err)
return
diff --git a/templates/repo/diff/comments.tmpl b/templates/repo/diff/comments.tmpl
index 59bc89b79..36e725936 100644
--- a/templates/repo/diff/comments.tmpl
+++ b/templates/repo/diff/comments.tmpl
@@ -47,7 +47,7 @@
{{end}}
{{end}}
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $.root "ActionURL" (Printf "%s/comments/%d/reactions" $.root.RepoLink .ID) }}
- {{template "repo/issue/view_content/context_menu" Dict "ctx" $.root "item" . "delete" true "diff" true "IsCommentPoster" (and $.root.IsSigned (eq $.root.SignedUserID .PosterID))}}
+ {{template "repo/issue/view_content/context_menu" Dict "ctx" $.root "item" . "delete" true "issue" false "diff" true "IsCommentPoster" (and $.root.IsSigned (eq $.root.SignedUserID .PosterID))}}
diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl
index 8f5426b83..abf5792a9 100644
--- a/templates/repo/issue/view_content/comments.tmpl
+++ b/templates/repo/issue/view_content/comments.tmpl
@@ -58,7 +58,7 @@
{{end}}
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID)}}
- {{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" . "delete" true "diff" false "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}}
+ {{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" . "delete" true "issue" true "diff" false "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}}
{{end}}
@@ -494,25 +494,49 @@
{{end}}
-