Skip to content

Commit cefe080

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Move mail notification logic to service layer (go-gitea#26905) Improve DeleteByID (go-gitea#26904) Update backup instructions to align with archive structure (go-gitea#26902) More fixes for the "commit-body" (go-gitea#26898) Show queue's active worker number (go-gitea#26896) Remove CSS `has` selector and improve various styles (go-gitea#26891)
2 parents 258382e + a66d883 commit cefe080

File tree

15 files changed

+83
-80
lines changed

15 files changed

+83
-80
lines changed

docs/content/administration/backup-and-restore.en-us.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ directory. There should be some output similar to the following:
4343
Inside the `gitea-dump-1482906742.zip` file, will be the following:
4444

4545
- `app.ini` - Optional copy of configuration file if originally stored outside the default `custom/` directory
46-
- `custom` - All config or customization files in `custom/`.
47-
- `data` - Data directory (APP_DATA_PATH), except sessions if you are using file session. This directory includes `attachments`, `avatars`, `lfs`, `indexers`, SQLite file if you are using SQLite.
46+
- `custom/` - All config or customization files in `custom/`.
47+
- `data/` - Data directory (APP_DATA_PATH), except sessions if you are using file session. This directory includes `attachments`, `avatars`, `lfs`, `indexers`, SQLite file if you are using SQLite.
48+
- `repos/` - Complete copy of the repository directory.
4849
- `gitea-db.sql` - SQL dump of database
49-
- `gitea-repo.zip` - Complete copy of the repository directory.
5050
- `log/` - Various logs. They are not needed for a recovery or migration.
5151

5252
Intermediate backup files are created in a temporary directory specified either with the
@@ -89,10 +89,10 @@ Example:
8989
```sh
9090
unzip gitea-dump-1610949662.zip
9191
cd gitea-dump-1610949662
92-
mv data/conf/app.ini /etc/gitea/conf/app.ini
92+
mv app.ini /etc/gitea/conf/app.ini
9393
mv data/* /var/lib/gitea/data/
9494
mv log/* /var/lib/gitea/log/
95-
mv repos/* /var/lib/gitea/repositories/
95+
mv repos/* /var/lib/gitea/gitea-repositories/
9696
chown -R gitea:gitea /etc/gitea/conf/app.ini /var/lib/gitea
9797

9898
# mysql
@@ -126,7 +126,7 @@ cd gitea-dump-1610949662
126126
# restore the gitea data
127127
mv data/* /data/gitea
128128
# restore the repositories itself
129-
mv repos/* /data/git/repositories/
129+
mv repos/* /data/git/gitea-repositories/
130130
# adjust file permissions
131131
chown -R git:git /data
132132
# Regenerate Git Hooks
@@ -150,7 +150,7 @@ mv data/conf/app.ini /etc/gitea/app.ini
150150
# restore the gitea data
151151
mv data/* /var/lib/gitea
152152
# restore the repositories itself
153-
mv repos/* /var/lib/gitea/git/repositories
153+
mv repos/* /var/lib/gitea/git/gitea-repositories
154154
# adjust file permissions
155155
chown -R git:git /etc/gitea/app.ini /var/lib/gitea
156156
# Regenerate Git Hooks

models/db/context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ func DeleteByBean(ctx context.Context, bean any) (int64, error) {
185185

186186
// DeleteByID deletes the given bean with the given ID
187187
func DeleteByID(ctx context.Context, id int64, bean any) (int64, error) {
188-
return GetEngine(ctx).ID(id).NoAutoTime().Delete(bean)
188+
return GetEngine(ctx).ID(id).NoAutoCondition().NoAutoTime().Delete(bean)
189189
}
190190

191191
// FindIDs finds the IDs for the given table name satisfying the given condition

modules/notification/notification.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ import (
1515
"code.gitea.io/gitea/modules/notification/action"
1616
"code.gitea.io/gitea/modules/notification/base"
1717
"code.gitea.io/gitea/modules/notification/indexer"
18-
"code.gitea.io/gitea/modules/notification/mail"
1918
"code.gitea.io/gitea/modules/notification/ui"
2019
"code.gitea.io/gitea/modules/repository"
21-
"code.gitea.io/gitea/modules/setting"
2220
)
2321

2422
var notifiers []base.Notifier
@@ -32,9 +30,6 @@ func RegisterNotifier(notifier base.Notifier) {
3230
// NewContext registers notification handlers
3331
func NewContext() {
3432
RegisterNotifier(ui.NewNotifier())
35-
if setting.Service.EnableNotifyMail {
36-
RegisterNotifier(mail.NewNotifier())
37-
}
3833
RegisterNotifier(indexer.NewNotifier())
3934
RegisterNotifier(action.NewNotifier())
4035
}

options/locale/locale_en-US.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3164,10 +3164,10 @@ monitor.queue.name = Name
31643164
monitor.queue.type = Type
31653165
monitor.queue.exemplar = Exemplar Type
31663166
monitor.queue.numberworkers = Number of Workers
3167+
monitor.queue.activeworkers = Active Workers
31673168
monitor.queue.maxnumberworkers = Max Number of Workers
31683169
monitor.queue.numberinqueue = Number in Queue
3169-
monitor.queue.review = Review Config
3170-
monitor.queue.review_add = Review/Add Workers
3170+
monitor.queue.review_add = Review / Add Workers
31713171
monitor.queue.settings.title = Pool Settings
31723172
monitor.queue.settings.desc = Pools dynamically grow in response to their worker queue blocking.
31733173
monitor.queue.settings.maxnumberworkers = Max Number of workers

services/mailer/mailer.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"code.gitea.io/gitea/modules/base"
2222
"code.gitea.io/gitea/modules/graceful"
2323
"code.gitea.io/gitea/modules/log"
24+
"code.gitea.io/gitea/modules/notification"
2425
"code.gitea.io/gitea/modules/process"
2526
"code.gitea.io/gitea/modules/queue"
2627
"code.gitea.io/gitea/modules/setting"
@@ -392,6 +393,10 @@ func NewContext(ctx context.Context) {
392393
return
393394
}
394395

396+
if setting.Service.EnableNotifyMail {
397+
notification.RegisterNotifier(NewNotifier())
398+
}
399+
395400
switch setting.MailService.Protocol {
396401
case "sendmail":
397402
Sender = &sendmailSender{}

modules/notification/mail/mail.go renamed to services/mailer/notify.go

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2019 The Gitea Authors. All rights reserved.
22
// SPDX-License-Identifier: MIT
33

4-
package mail
4+
package mailer
55

66
import (
77
"context"
@@ -13,7 +13,6 @@ import (
1313
user_model "code.gitea.io/gitea/models/user"
1414
"code.gitea.io/gitea/modules/log"
1515
"code.gitea.io/gitea/modules/notification/base"
16-
"code.gitea.io/gitea/services/mailer"
1716
)
1817

1918
type mailNotifier struct {
@@ -43,13 +42,13 @@ func (m *mailNotifier) NotifyCreateIssueComment(ctx context.Context, doer *user_
4342
act = 0
4443
}
4544

46-
if err := mailer.MailParticipantsComment(ctx, comment, act, issue, mentions); err != nil {
45+
if err := MailParticipantsComment(ctx, comment, act, issue, mentions); err != nil {
4746
log.Error("MailParticipantsComment: %v", err)
4847
}
4948
}
5049

5150
func (m *mailNotifier) NotifyNewIssue(ctx context.Context, issue *issues_model.Issue, mentions []*user_model.User) {
52-
if err := mailer.MailParticipants(ctx, issue, issue.Poster, activities_model.ActionCreateIssue, mentions); err != nil {
51+
if err := MailParticipants(ctx, issue, issue.Poster, activities_model.ActionCreateIssue, mentions); err != nil {
5352
log.Error("MailParticipants: %v", err)
5453
}
5554
}
@@ -70,7 +69,7 @@ func (m *mailNotifier) NotifyIssueChangeStatus(ctx context.Context, doer *user_m
7069
}
7170
}
7271

73-
if err := mailer.MailParticipants(ctx, issue, doer, actionType, nil); err != nil {
72+
if err := MailParticipants(ctx, issue, doer, actionType, nil); err != nil {
7473
log.Error("MailParticipants: %v", err)
7574
}
7675
}
@@ -81,14 +80,14 @@ func (m *mailNotifier) NotifyIssueChangeTitle(ctx context.Context, doer *user_mo
8180
return
8281
}
8382
if issue.IsPull && issues_model.HasWorkInProgressPrefix(oldTitle) && !issue.PullRequest.IsWorkInProgress() {
84-
if err := mailer.MailParticipants(ctx, issue, doer, activities_model.ActionPullRequestReadyForReview, nil); err != nil {
83+
if err := MailParticipants(ctx, issue, doer, activities_model.ActionPullRequestReadyForReview, nil); err != nil {
8584
log.Error("MailParticipants: %v", err)
8685
}
8786
}
8887
}
8988

9089
func (m *mailNotifier) NotifyNewPullRequest(ctx context.Context, pr *issues_model.PullRequest, mentions []*user_model.User) {
91-
if err := mailer.MailParticipants(ctx, pr.Issue, pr.Issue.Poster, activities_model.ActionCreatePullRequest, mentions); err != nil {
90+
if err := MailParticipants(ctx, pr.Issue, pr.Issue.Poster, activities_model.ActionCreatePullRequest, mentions); err != nil {
9291
log.Error("MailParticipants: %v", err)
9392
}
9493
}
@@ -102,13 +101,13 @@ func (m *mailNotifier) NotifyPullRequestReview(ctx context.Context, pr *issues_m
102101
} else if comment.Type == issues_model.CommentTypeComment {
103102
act = activities_model.ActionCommentPull
104103
}
105-
if err := mailer.MailParticipantsComment(ctx, comment, act, pr.Issue, mentions); err != nil {
104+
if err := MailParticipantsComment(ctx, comment, act, pr.Issue, mentions); err != nil {
106105
log.Error("MailParticipantsComment: %v", err)
107106
}
108107
}
109108

110109
func (m *mailNotifier) NotifyPullRequestCodeComment(ctx context.Context, pr *issues_model.PullRequest, comment *issues_model.Comment, mentions []*user_model.User) {
111-
if err := mailer.MailMentionsComment(ctx, pr, comment, mentions); err != nil {
110+
if err := MailMentionsComment(ctx, pr, comment, mentions); err != nil {
112111
log.Error("MailMentionsComment: %v", err)
113112
}
114113
}
@@ -117,7 +116,7 @@ func (m *mailNotifier) NotifyIssueChangeAssignee(ctx context.Context, doer *user
117116
// mail only sent to added assignees and not self-assignee
118117
if !removed && doer.ID != assignee.ID && assignee.EmailNotifications() != user_model.EmailNotificationsDisabled {
119118
ct := fmt.Sprintf("Assigned #%d.", issue.Index)
120-
if err := mailer.SendIssueAssignedMail(ctx, issue, doer, ct, comment, []*user_model.User{assignee}); err != nil {
119+
if err := SendIssueAssignedMail(ctx, issue, doer, ct, comment, []*user_model.User{assignee}); err != nil {
121120
log.Error("Error in SendIssueAssignedMail for issue[%d] to assignee[%d]: %v", issue.ID, assignee.ID, err)
122121
}
123122
}
@@ -126,7 +125,7 @@ func (m *mailNotifier) NotifyIssueChangeAssignee(ctx context.Context, doer *user
126125
func (m *mailNotifier) NotifyPullRequestReviewRequest(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, reviewer *user_model.User, isRequest bool, comment *issues_model.Comment) {
127126
if isRequest && doer.ID != reviewer.ID && reviewer.EmailNotifications() != user_model.EmailNotificationsDisabled {
128127
ct := fmt.Sprintf("Requested to review %s.", issue.HTMLURL())
129-
if err := mailer.SendIssueAssignedMail(ctx, issue, doer, ct, comment, []*user_model.User{reviewer}); err != nil {
128+
if err := SendIssueAssignedMail(ctx, issue, doer, ct, comment, []*user_model.User{reviewer}); err != nil {
130129
log.Error("Error in SendIssueAssignedMail for issue[%d] to reviewer[%d]: %v", issue.ID, reviewer.ID, err)
131130
}
132131
}
@@ -137,7 +136,7 @@ func (m *mailNotifier) NotifyMergePullRequest(ctx context.Context, doer *user_mo
137136
log.Error("LoadIssue: %v", err)
138137
return
139138
}
140-
if err := mailer.MailParticipants(ctx, pr.Issue, doer, activities_model.ActionMergePullRequest, nil); err != nil {
139+
if err := MailParticipants(ctx, pr.Issue, doer, activities_model.ActionMergePullRequest, nil); err != nil {
141140
log.Error("MailParticipants: %v", err)
142141
}
143142
}
@@ -147,7 +146,7 @@ func (m *mailNotifier) NotifyAutoMergePullRequest(ctx context.Context, doer *use
147146
log.Error("pr.LoadIssue: %v", err)
148147
return
149148
}
150-
if err := mailer.MailParticipants(ctx, pr.Issue, doer, activities_model.ActionAutoMergePullRequest, nil); err != nil {
149+
if err := MailParticipants(ctx, pr.Issue, doer, activities_model.ActionAutoMergePullRequest, nil); err != nil {
151150
log.Error("MailParticipants: %v", err)
152151
}
153152
}
@@ -177,7 +176,7 @@ func (m *mailNotifier) NotifyPullRequestPushCommits(ctx context.Context, doer *u
177176
}
178177

179178
func (m *mailNotifier) NotifyPullReviewDismiss(ctx context.Context, doer *user_model.User, review *issues_model.Review, comment *issues_model.Comment) {
180-
if err := mailer.MailParticipantsComment(ctx, comment, activities_model.ActionPullReviewDismissed, review.Issue, nil); err != nil {
179+
if err := MailParticipantsComment(ctx, comment, activities_model.ActionPullReviewDismissed, review.Issue, nil); err != nil {
181180
log.Error("MailParticipantsComment: %v", err)
182181
}
183182
}
@@ -192,11 +191,11 @@ func (m *mailNotifier) NotifyNewRelease(ctx context.Context, rel *repo_model.Rel
192191
return
193192
}
194193

195-
mailer.MailNewRelease(ctx, rel)
194+
MailNewRelease(ctx, rel)
196195
}
197196

198197
func (m *mailNotifier) NotifyRepoPendingTransfer(ctx context.Context, doer, newOwner *user_model.User, repo *repo_model.Repository) {
199-
if err := mailer.SendRepoTransferNotifyMail(ctx, doer, newOwner, repo); err != nil {
198+
if err := SendRepoTransferNotifyMail(ctx, doer, newOwner, repo); err != nil {
200199
log.Error("SendRepoTransferNotifyMail: %v", err)
201200
}
202201
}

templates/admin/queue.tmpl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<th>{{.locale.Tr "admin.monitor.queue.type"}}</th>
1212
<th>{{.locale.Tr "admin.monitor.queue.exemplar"}}</th>
1313
<th>{{.locale.Tr "admin.monitor.queue.numberworkers"}}</th>
14+
<th>{{.locale.Tr "admin.monitor.queue.activeworkers"}}</th>
1415
<th>{{.locale.Tr "admin.monitor.queue.numberinqueue"}}</th>
1516
<th></th>
1617
</tr>
@@ -21,9 +22,10 @@
2122
<td>{{$q.GetName}}</td>
2223
<td>{{$q.GetType}}</td>
2324
<td>{{$q.GetItemTypeName}}</td>
24-
<td>{{$sum := $q.GetWorkerNumber}}{{if lt $sum 0}}-{{else}}{{$sum}}{{end}}</td>
25-
<td>{{$sum = $q.GetQueueItemNumber}}{{if lt $sum 0}}-{{else}}{{$sum}}{{end}}</td>
26-
<td><a href="{{$.Link}}/{{$qid}}" class="button">{{if lt $sum 0}}{{$.locale.Tr "admin.monitor.queue.review"}}{{else}}{{$.locale.Tr "admin.monitor.queue.review_add"}}{{end}}</a></td>
25+
<td>{{$q.GetWorkerNumber}}</td>
26+
<td>{{$q.GetWorkerActiveNumber}}</td>
27+
<td>{{$sum := $q.GetQueueItemNumber}}{{if lt $sum 0}}-{{else}}{{$sum}}{{end}}</td>
28+
<td><a href="{{$.Link}}/{{$qid}}" class="button">{{$.locale.Tr "admin.monitor.queue.review_add"}}</a></td>
2729
</tr>
2830
{{end}}
2931
</tbody>

templates/admin/queue_manage.tmpl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<th>{{.locale.Tr "admin.monitor.queue.type"}}</th>
1212
<th>{{.locale.Tr "admin.monitor.queue.exemplar"}}</th>
1313
<th>{{.locale.Tr "admin.monitor.queue.numberworkers"}}</th>
14+
<th>{{.locale.Tr "admin.monitor.queue.activeworkers"}}</th>
1415
<th>{{.locale.Tr "admin.monitor.queue.maxnumberworkers"}}</th>
1516
<th>{{.locale.Tr "admin.monitor.queue.numberinqueue"}}</th>
1617
</tr>
@@ -20,10 +21,11 @@
2021
<td>{{.Queue.GetName}}</td>
2122
<td>{{.Queue.GetType}}</td>
2223
<td>{{.Queue.GetItemTypeName}}</td>
23-
<td>{{$sum := .Queue.GetWorkerNumber}}{{if lt $sum 0}}-{{else}}{{$sum}}{{end}}</td>
24-
<td>{{if lt $sum 0}}-{{else}}{{.Queue.GetWorkerMaxNumber}}{{end}}</td>
24+
<td>{{.Queue.GetWorkerNumber}}</td>
25+
<td>{{.Queue.GetWorkerActiveNumber}}</td>
26+
<td>{{.Queue.GetWorkerMaxNumber}}</td>
2527
<td>
26-
{{$sum = .Queue.GetQueueItemNumber}}
28+
{{$sum := .Queue.GetQueueItemNumber}}
2729
{{if lt $sum 0}}
2830
-
2931
{{else}}

templates/devtest/gitea-ui.tmpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@
7979
</div>
8080
</div>
8181

82+
<div>
83+
<h1>Buttons</h1>
84+
<div class="ui buttons"><button class="ui button">1</button><button class="ui button">2</button><button class="ui button">3</button></div>
85+
<div class="ui buttons"><button class="ui button active">1</button><button class="ui button">2</button><button class="ui button">3</button></div>
86+
<div class="ui buttons"><button class="ui button">1</button><button class="ui button active">2</button><button class="ui button">3</button></div>
87+
<div class="ui buttons"><button class="ui button">1</button><button class="ui button">2</button><button class="ui button active">3</button></div>
88+
</div>
89+
8290
<div>
8391
<h1>Tooltip</h1>
8492
<div><span data-tooltip-content="test tooltip">text with tooltip</span></div>

templates/repo/commit_page.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
{{end}}
136136
</div>
137137
{{if IsMultilineCommitMessage .Commit.Message}}
138-
<pre class="commit-body gt-mt-0">{{RenderCommitBody $.Context .Commit.Message $.RepoLink $.Repository.ComposeMetas}}</pre>
138+
<pre class="commit-body">{{RenderCommitBody $.Context .Commit.Message $.RepoLink $.Repository.ComposeMetas}}</pre>
139139
{{end}}
140140
{{template "repo/commit_load_branches_and_tags" .}}
141141
</div>

0 commit comments

Comments
 (0)