Skip to content

Commit ddef710

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Fix mail template error (go-gitea#29410) Document our issue locking policy (go-gitea#29433) Fix htmx rendering the login page in frame on session logout (go-gitea#29405) Ignore empty repo for CreateRepository in action notifier (go-gitea#29416) Fix incorrect tree path value for patch editor (go-gitea#29377) Fix logic error from go-gitea#28138 (go-gitea#29417)
2 parents 2575481 + eb2fc18 commit ddef710

File tree

7 files changed

+31
-6
lines changed

7 files changed

+31
-6
lines changed

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- [How to report issues](#how-to-report-issues)
99
- [Types of issues](#types-of-issues)
1010
- [Discuss your design before the implementation](#discuss-your-design-before-the-implementation)
11+
- [Issue locking](#issue-locking)
1112
- [Building Gitea](#building-gitea)
1213
- [Dependencies](#dependencies)
1314
- [Backend](#backend)
@@ -103,6 +104,13 @@ the goals for the project and tools.
103104

104105
Pull requests should not be the place for architecture discussions.
105106

107+
### Issue locking
108+
109+
Commenting on closed or merged issues/PRs is strongly discouraged.
110+
Such comments will likely be overlooked as some maintainers may not view notifications on closed issues, thinking that the item is resolved.
111+
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.
112+
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.
113+
106114
## Building Gitea
107115

108116
See the [development setup instructions](https://docs.gitea.com/development/hacking-on-gitea).

modules/context/base.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,14 @@ func (b *Base) Redirect(location string, status ...int) {
265265
// So in this case, we should remove the session cookie from the response header
266266
removeSessionCookieHeader(b.Resp)
267267
}
268+
// in case the request is made by htmx, have it redirect the browser instead of trying to follow the redirect inside htmx
269+
if b.Req.Header.Get("HX-Request") == "true" {
270+
b.Resp.Header().Set("HX-Redirect", location)
271+
// we have to return a non-redirect status code so XMLHTTPRequest will not immediately follow the redirect
272+
// so as to give htmx redirect logic a chance to run
273+
b.Status(http.StatusNoContent)
274+
return
275+
}
268276
http.Redirect(b.Resp, b.Req, location, code)
269277
}
270278

modules/templates/mailer.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,17 @@ func buildSubjectBodyTemplate(stpl *texttmpl.Template, btpl *template.Template,
4444
}
4545
if _, err := stpl.New(name).
4646
Parse(string(subjectContent)); err != nil {
47-
log.Warn("Failed to parse template [%s/subject]: %v", name, err)
47+
log.Error("Failed to parse template [%s/subject]: %v", name, err)
48+
if !setting.IsProd {
49+
log.Fatal("Please fix the mail template error")
50+
}
4851
}
4952
if _, err := btpl.New(name).
5053
Parse(string(bodyContent)); err != nil {
51-
log.Warn("Failed to parse template [%s/body]: %v", name, err)
54+
log.Error("Failed to parse template [%s/body]: %v", name, err)
55+
if !setting.IsProd {
56+
log.Fatal("Please fix the mail template error")
57+
}
5258
}
5359
}
5460

routers/private/hook_post_receive.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
159159
}
160160

161161
// If we've pushed a branch (and not deleted it)
162-
if git.IsEmptyCommitID(newCommitID) && refFullName.IsBranch() {
162+
if !git.IsEmptyCommitID(newCommitID) && refFullName.IsBranch() {
163163
// First ensure we have the repository loaded, we're allowed pulls requests and we can get the base repo
164164
if repo == nil {
165165
repo = loadRepository(ctx, ownerName, repoName)

services/actions/notifier_helper.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ func notify(ctx context.Context, input *notifyInput) error {
117117
log.Debug("ignore executing %v for event %v whose doer is %v", getMethod(ctx), input.Event, input.Doer.Name)
118118
return nil
119119
}
120+
if input.Repo.IsEmpty {
121+
return nil
122+
}
120123
if unit_model.TypeActions.UnitGlobalDisabled() {
121124
if err := actions_model.CleanRepoScheduleTasks(ctx, input.Repo); err != nil {
122125
log.Error("CleanRepoScheduleTasks: %v", err)

templates/mail/notify/repo_transfer.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<title>{{.Subject}}</title>
66
</head>
77

8-
{{$url := HTMLFormat "<a href='%[1]s'>%[2]s</a>" .Link .Repo)}}
8+
{{$url := HTMLFormat "<a href='%[1]s'>%[2]s</a>" .Link .Repo}}
99
<body>
1010
<p>{{.Subject}}.
1111
{{.locale.Tr "mail.repo.transfer.body" $url}}

templates/repo/editor/patch.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
<div class="breadcrumb-divider">:</div>
1515
<a class="section" href="{{$.BranchLink}}">{{.BranchName}}</a>
1616
<span>{{ctx.Locale.Tr "repo.editor.or"}} <a href="{{$.BranchLink}}">{{ctx.Locale.Tr "repo.editor.cancel_lower"}}</a></span>
17-
<input type="hidden" id="tree_path" name="tree_path" value="" required>
18-
<input id="file-name" maxlength="500" type="hidden" value="diff.patch">
17+
<input type="hidden" name="tree_path" value="__dummy_for_EditRepoFileForm.TreePath(Required)__">
18+
<input id="file-name" type="hidden" value="diff.patch">
1919
</div>
2020
</div>
2121
<div class="field">

0 commit comments

Comments
 (0)