Skip to content

Commit

Permalink
Merge remote-tracking branch 'giteaofficial/main'
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
zjjhot committed Feb 27, 2024
2 parents 2575481 + eb2fc18 commit ddef710
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 6 deletions.
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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).
Expand Down
8 changes: 8 additions & 0 deletions modules/context/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
10 changes: 8 additions & 2 deletions modules/templates/mailer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion routers/private/hook_post_receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions services/actions/notifier_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion templates/mail/notify/repo_transfer.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>{{.Subject}}</title>
</head>

{{$url := HTMLFormat "<a href='%[1]s'>%[2]s</a>" .Link .Repo)}}
{{$url := HTMLFormat "<a href='%[1]s'>%[2]s</a>" .Link .Repo}}
<body>
<p>{{.Subject}}.
{{.locale.Tr "mail.repo.transfer.body" $url}}
Expand Down
4 changes: 2 additions & 2 deletions templates/repo/editor/patch.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<div class="breadcrumb-divider">:</div>
<a class="section" href="{{$.BranchLink}}">{{.BranchName}}</a>
<span>{{ctx.Locale.Tr "repo.editor.or"}} <a href="{{$.BranchLink}}">{{ctx.Locale.Tr "repo.editor.cancel_lower"}}</a></span>
<input type="hidden" id="tree_path" name="tree_path" value="" required>
<input id="file-name" maxlength="500" type="hidden" value="diff.patch">
<input type="hidden" name="tree_path" value="__dummy_for_EditRepoFileForm.TreePath(Required)__">
<input id="file-name" type="hidden" value="diff.patch">
</div>
</div>
<div class="field">
Expand Down

0 comments on commit ddef710

Please sign in to comment.