From f8c1efe944c539396402fb014bbfdb67ba199ef2 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Mon, 26 Feb 2024 17:10:14 +0900 Subject: [PATCH 1/6] Fix logic error from #28138 (#29417) There's a miss in #28138: ![image](https://github.com/go-gitea/gitea/assets/18380374/b1e0c5fc-0e6e-44ab-9f6e-34bc8ffbe1cc) https://github.com/go-gitea/gitea/pull/28138/files#diff-2556e62ad7204a230c91927a3f2115e25a2b688240d0ee1de6d34f0277f37dfeR162 @lunny Not sure about the impact of this, but it will only effect 1.22, and maybe we should fix it ASAP. Co-authored-by: KN4CK3R --- routers/private/hook_post_receive.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/private/hook_post_receive.go b/routers/private/hook_post_receive.go index 8b954a8130ce..5ae03ce294b5 100644 --- a/routers/private/hook_post_receive.go +++ b/routers/private/hook_post_receive.go @@ -159,7 +159,7 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) { } // If we've pushed a branch (and not deleted it) - if git.IsEmptyCommitID(newCommitID) && refFullName.IsBranch() { + if !git.IsEmptyCommitID(newCommitID) && refFullName.IsBranch() { // First ensure we have the repository loaded, we're allowed pulls requests and we can get the base repo if repo == nil { repo = loadRepository(ctx, ownerName, repoName) From f8974c772560e2c957e5e218bfb348d1ee6b9448 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Mon, 26 Feb 2024 17:05:22 +0800 Subject: [PATCH 2/6] Fix incorrect tree path value for patch editor (#29377) Regression of #18718. When submitting the form, EditRepoFileForm.TreePath is marked as "Required", so the value can't be empty. The value is not used by backend, so use a meaningful dummy value for it. --- templates/repo/editor/patch.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/repo/editor/patch.tmpl b/templates/repo/editor/patch.tmpl index c9a78cc35fdf..8df87589889b 100644 --- a/templates/repo/editor/patch.tmpl +++ b/templates/repo/editor/patch.tmpl @@ -14,8 +14,8 @@ {{.BranchName}} {{ctx.Locale.Tr "repo.editor.or"}} {{ctx.Locale.Tr "repo.editor.cancel_lower"}} - - + +
From 403766cd81697288804fd218d68c458c6aa5b73d Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Mon, 26 Feb 2024 18:38:15 +0900 Subject: [PATCH 3/6] Ignore empty repo for CreateRepository in action notifier (#29416) Fix #29415 --- services/actions/notifier_helper.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/actions/notifier_helper.go b/services/actions/notifier_helper.go index c20335af6f30..b248af1d0183 100644 --- a/services/actions/notifier_helper.go +++ b/services/actions/notifier_helper.go @@ -117,6 +117,9 @@ func notify(ctx context.Context, input *notifyInput) error { log.Debug("ignore executing %v for event %v whose doer is %v", getMethod(ctx), input.Event, input.Doer.Name) return nil } + if input.Repo.IsEmpty { + return nil + } if unit_model.TypeActions.UnitGlobalDisabled() { if err := actions_model.CleanRepoScheduleTasks(ctx, input.Repo); err != nil { log.Error("CleanRepoScheduleTasks: %v", err) From 324626a11c041208b003ee64e33000b223994662 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Mon, 26 Feb 2024 14:40:41 +0200 Subject: [PATCH 4/6] Fix htmx rendering the login page in frame on session logout (#29405) - Fix #29391 With this change, htmx will not follow the redirect in the AJAX request but instead redirect the whole browser. To reproduce the bug fixed by this change without waiting a long time for the token to expire, you can logout in another tab then look in the original tab. Just make sure to comment out both instances of `window.location.href = appSubUrl` in the codebase so you won't be redirected immediately on logout. This is what I did in the following gifs. Signed-off-by: Yarden Shoham Co-authored-by: Giteabot --- modules/context/base.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/context/base.go b/modules/context/base.go index fa05850a166b..ddd04f476745 100644 --- a/modules/context/base.go +++ b/modules/context/base.go @@ -265,6 +265,14 @@ func (b *Base) Redirect(location string, status ...int) { // So in this case, we should remove the session cookie from the response header removeSessionCookieHeader(b.Resp) } + // in case the request is made by htmx, have it redirect the browser instead of trying to follow the redirect inside htmx + if b.Req.Header.Get("HX-Request") == "true" { + b.Resp.Header().Set("HX-Redirect", location) + // we have to return a non-redirect status code so XMLHTTPRequest will not immediately follow the redirect + // so as to give htmx redirect logic a chance to run + b.Status(http.StatusNoContent) + return + } http.Redirect(b.Resp, b.Req, location, code) } From 4f70ebb68494b23c5bce93efbe4c5f80b3aaf444 Mon Sep 17 00:00:00 2001 From: delvh Date: Mon, 26 Feb 2024 23:04:44 +0100 Subject: [PATCH 5/6] Document our issue locking policy (#29433) --- CONTRIBUTING.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f9b9a421a372..dc90c6905b9d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,6 +8,7 @@ - [How to report issues](#how-to-report-issues) - [Types of issues](#types-of-issues) - [Discuss your design before the implementation](#discuss-your-design-before-the-implementation) + - [Issue locking](#issue-locking) - [Building Gitea](#building-gitea) - [Dependencies](#dependencies) - [Backend](#backend) @@ -103,6 +104,13 @@ the goals for the project and tools. Pull requests should not be the place for architecture discussions. +### Issue locking + +Commenting on closed or merged issues/PRs is strongly discouraged. +Such comments will likely be overlooked as some maintainers may not view notifications on closed issues, thinking that the item is resolved. +As such, commenting on closed/merged issues/PRs may be disabled prior to the scheduled auto-locking if a discussion starts or if unrelated comments are posted. +If further discussion is needed, we encourage you to open a new issue instead and we recommend linking to the issue/PR in question for context. + ## Building Gitea See the [development setup instructions](https://docs.gitea.com/development/hacking-on-gitea). From eb2fc1818b00b7ca6f8c21bb490a8e8be1e62f9a Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Tue, 27 Feb 2024 06:31:30 +0800 Subject: [PATCH 6/6] Fix mail template error (#29410) --- modules/templates/mailer.go | 10 ++++++++-- templates/mail/notify/repo_transfer.tmpl | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/templates/mailer.go b/modules/templates/mailer.go index 54d857a8f6e8..04032e398278 100644 --- a/modules/templates/mailer.go +++ b/modules/templates/mailer.go @@ -44,11 +44,17 @@ func buildSubjectBodyTemplate(stpl *texttmpl.Template, btpl *template.Template, } if _, err := stpl.New(name). Parse(string(subjectContent)); err != nil { - log.Warn("Failed to parse template [%s/subject]: %v", name, err) + log.Error("Failed to parse template [%s/subject]: %v", name, err) + if !setting.IsProd { + log.Fatal("Please fix the mail template error") + } } if _, err := btpl.New(name). Parse(string(bodyContent)); err != nil { - log.Warn("Failed to parse template [%s/body]: %v", name, err) + log.Error("Failed to parse template [%s/body]: %v", name, err) + if !setting.IsProd { + log.Fatal("Please fix the mail template error") + } } } diff --git a/templates/mail/notify/repo_transfer.tmpl b/templates/mail/notify/repo_transfer.tmpl index 597048ddf496..8c8b276484e1 100644 --- a/templates/mail/notify/repo_transfer.tmpl +++ b/templates/mail/notify/repo_transfer.tmpl @@ -5,7 +5,7 @@ {{.Subject}} -{{$url := HTMLFormat "%[2]s" .Link .Repo)}} +{{$url := HTMLFormat "%[2]s" .Link .Repo}}

{{.Subject}}. {{.locale.Tr "mail.repo.transfer.body" $url}}