Skip to content

Commit 5a0b68b

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Add missing comment reply handling (go-gitea#32050) Fix CI (go-gitea#32062) Lazy load avatar images (go-gitea#32051) Included tag search capabilities (go-gitea#32045) Do not escape relative path in RPM primary index (go-gitea#32038) feat(go-gitea#31666): Set the columns height to hug all its contents (go-gitea#31726) [skip ci] Updated translations via Crowdin [skip ci] Updated translations via Crowdin Use a common message template instead of a special one (go-gitea#31878) Check if the `due_date` is nil when editing issues (go-gitea#32035)
2 parents 55d51e2 + 55f1fcf commit 5a0b68b

File tree

15 files changed

+230
-188
lines changed

15 files changed

+230
-188
lines changed

go.mod

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ module code.gitea.io/gitea
22

33
go 1.23
44

5+
// rfc5280 said: "The serial number is an integer assigned by the CA to each certificate."
6+
// But some CAs use negative serial number, just relax the check. related:
7+
// Default TLS cert uses negative serial number #895 https://github.com/microsoft/mssql-docker/issues/895
8+
godebug x509negativeserial=1
9+
510
require (
611
code.gitea.io/actions-proto-go v0.4.0
712
code.gitea.io/gitea-vet v0.2.3

models/repo/release.go

+6
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ type FindReleasesOptions struct {
234234
IsDraft optional.Option[bool]
235235
TagNames []string
236236
HasSha1 optional.Option[bool] // useful to find draft releases which are created with existing tags
237+
NamePattern optional.Option[string]
237238
}
238239

239240
func (opts FindReleasesOptions) ToConds() builder.Cond {
@@ -261,6 +262,11 @@ func (opts FindReleasesOptions) ToConds() builder.Cond {
261262
cond = cond.And(builder.Eq{"sha1": ""})
262263
}
263264
}
265+
266+
if opts.NamePattern.Has() && opts.NamePattern.Value() != "" {
267+
cond = cond.And(builder.Like{"lower_tag_name", strings.ToLower(opts.NamePattern.Value())})
268+
}
269+
264270
return cond
265271
}
266272

modules/templates/util_avatar.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func AvatarHTML(src string, size int, class, name string) template.HTML {
3434
name = "avatar"
3535
}
3636

37-
return template.HTML(`<img class="` + class + `" src="` + src + `" title="` + html.EscapeString(name) + `" width="` + sizeStr + `" height="` + sizeStr + `"/>`)
37+
return template.HTML(`<img loading="lazy" class="` + class + `" src="` + src + `" title="` + html.EscapeString(name) + `" width="` + sizeStr + `" height="` + sizeStr + `"/>`)
3838
}
3939

4040
// Avatar renders user avatars. args: user, size (int), class (string)

options/locale/locale_en-US.ini

+3-1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ filter.public = Public
159159
filter.private = Private
160160

161161
no_results_found = No results found.
162+
internal_error_skipped = Internal error occurred but is skipped: %s
162163

163164
[search]
164165
search = Search...
@@ -177,6 +178,8 @@ code_search_by_git_grep = Current code search results are provided by "git grep"
177178
package_kind = Search packages...
178179
project_kind = Search projects...
179180
branch_kind = Search branches...
181+
tag_kind = Search tags...
182+
tag_tooltip = Search for matching tags. Use '%' to match any sequence of numbers.
180183
commit_kind = Search commits...
181184
runner_kind = Search runners...
182185
no_results = No matching results found.
@@ -1279,7 +1282,6 @@ commit_graph.color = Color
12791282
commit.contained_in = This commit is contained in:
12801283
commit.contained_in_default_branch = This commit is part of the default branch
12811284
commit.load_referencing_branches_and_tags = Load branches and tags referencing this commit
1282-
commit.load_tags_failed = Load tags failed because of internal error
12831285
blame = Blame
12841286
download_file = Download file
12851287
normal_view = Normal View

options/locale/locale_fr-FR.ini

-1
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,6 @@ commit_graph.color=Couleur
12541254
commit.contained_in=Cette révision appartient à :
12551255
commit.contained_in_default_branch=Cette révision appartient à la branche par défaut
12561256
commit.load_referencing_branches_and_tags=Charger les branches et étiquettes référençant cette révision
1257-
commit.load_tags_failed=Le chargement des étiquettes a échoué à cause d’une erreur interne
12581257
blame=Annotations
12591258
download_file=Télécharger le fichier
12601259
normal_view=Vue normale

options/locale/locale_ja-JP.ini

-1
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,6 @@ commit_graph.color=カラー
12631263
commit.contained_in=このコミットが含まれているのは:
12641264
commit.contained_in_default_branch=このコミットはデフォルトブランチに含まれています
12651265
commit.load_referencing_branches_and_tags=このコミットを参照しているブランチやタグを取得
1266-
commit.load_tags_failed=内部エラーによりタグの読み込みに失敗しました
12671266
blame=Blame
12681267
download_file=ファイルをダウンロード
12691268
normal_view=通常表示

options/locale/locale_pt-PT.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ filter.public=Público
159159
filter.private=Privado
160160

161161
no_results_found=Não foram encontrados quaisquer resultados.
162+
internal_error_skipped=Ocorreu um erro interno mas foi ignorado: %s
162163

163164
[search]
164165
search=Pesquisar...
@@ -1279,7 +1280,6 @@ commit_graph.color=Colorido
12791280
commit.contained_in=Este cometimento está contido em:
12801281
commit.contained_in_default_branch=Este cometimento é parte do ramo principal
12811282
commit.load_referencing_branches_and_tags=Carregar ramos e etiquetas que referenciem este cometimento
1282-
commit.load_tags_failed=O carregamento das etiquetas falhou por causa de um erro interno
12831283
blame=Responsabilidade
12841284
download_file=Descarregar ficheiro
12851285
normal_view=Vista normal

routers/api/v1/repo/issue.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -833,10 +833,16 @@ func EditIssue(ctx *context.APIContext) {
833833
if (form.Deadline != nil || form.RemoveDeadline != nil) && canWrite {
834834
var deadlineUnix timeutil.TimeStamp
835835

836-
if (form.RemoveDeadline == nil || !*form.RemoveDeadline) && !form.Deadline.IsZero() {
837-
deadline := time.Date(form.Deadline.Year(), form.Deadline.Month(), form.Deadline.Day(),
838-
23, 59, 59, 0, form.Deadline.Location())
839-
deadlineUnix = timeutil.TimeStamp(deadline.Unix())
836+
if form.RemoveDeadline == nil || !*form.RemoveDeadline {
837+
if form.Deadline == nil {
838+
ctx.Error(http.StatusBadRequest, "", "The due_date cannot be empty")
839+
return
840+
}
841+
if !form.Deadline.IsZero() {
842+
deadline := time.Date(form.Deadline.Year(), form.Deadline.Month(), form.Deadline.Day(),
843+
23, 59, 59, 0, form.Deadline.Location())
844+
deadlineUnix = timeutil.TimeStamp(deadline.Unix())
845+
}
840846
}
841847

842848
if err := issues_model.UpdateIssueDeadline(ctx, issue, deadlineUnix, ctx.Doer); err != nil {

routers/web/repo/commit.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func Commits(ctx *context.Context) {
9090
commitsTagsMap, err := repo_model.FindTagsByCommitIDs(ctx, ctx.Repo.Repository.ID, commitIDs...)
9191
if err != nil {
9292
log.Error("FindTagsByCommitIDs: %v", err)
93-
ctx.Flash.Error(ctx.Tr("repo.commit.load_tags_failed"))
93+
ctx.Flash.Error(ctx.Tr("internal_error_skipped", "FindTagsByCommitIDs"))
9494
} else {
9595
ctx.Data["CommitsTagsMap"] = commitsTagsMap
9696
}

routers/web/repo/release.go

+13-3
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ func TagsList(ctx *context.Context) {
214214
ctx.Data["HideBranchesInDropdown"] = true
215215
ctx.Data["CanCreateRelease"] = ctx.Repo.CanWrite(unit.TypeReleases) && !ctx.Repo.Repository.IsArchived
216216

217+
namePattern := ctx.FormTrim("q")
218+
217219
listOptions := db.ListOptions{
218220
Page: ctx.FormInt("page"),
219221
PageSize: ctx.FormInt("limit"),
@@ -233,6 +235,7 @@ func TagsList(ctx *context.Context) {
233235
IncludeTags: true,
234236
HasSha1: optional.Some(true),
235237
RepoID: ctx.Repo.Repository.ID,
238+
NamePattern: optional.Some(namePattern),
236239
}
237240

238241
releases, err := db.Find[repo_model.Release](ctx, opts)
@@ -241,14 +244,21 @@ func TagsList(ctx *context.Context) {
241244
return
242245
}
243246

247+
count, err := db.Count[repo_model.Release](ctx, opts)
248+
if err != nil {
249+
ctx.ServerError("GetReleasesByRepoID", err)
250+
return
251+
}
252+
253+
ctx.Data["Keyword"] = namePattern
244254
ctx.Data["Releases"] = releases
255+
ctx.Data["TagCount"] = count
245256

246-
numTags := ctx.Data["NumTags"].(int64)
247-
pager := context.NewPagination(int(numTags), opts.PageSize, opts.Page, 5)
257+
pager := context.NewPagination(int(count), opts.PageSize, opts.Page, 5)
248258
pager.SetDefaultParams(ctx)
249259
ctx.Data["Page"] = pager
250-
251260
ctx.Data["PageIsViewCode"] = !ctx.Repo.Repository.UnitEnabled(ctx, unit.TypeReleases)
261+
252262
ctx.HTML(http.StatusOK, tplTagsList)
253263
}
254264

services/mailer/incoming/incoming_handler.go

+29-27
Original file line numberDiff line numberDiff line change
@@ -82,43 +82,40 @@ func (h *ReplyHandler) Handle(ctx context.Context, content *MailContent, doer *u
8282
return nil
8383
}
8484

85-
switch r := ref.(type) {
86-
case *issues_model.Issue:
87-
attachmentIDs := make([]string, 0, len(content.Attachments))
88-
if setting.Attachment.Enabled {
89-
for _, attachment := range content.Attachments {
90-
a, err := attachment_service.UploadAttachment(ctx, bytes.NewReader(attachment.Content), setting.Attachment.AllowedTypes, int64(len(attachment.Content)), &repo_model.Attachment{
91-
Name: attachment.Name,
92-
UploaderID: doer.ID,
93-
RepoID: issue.Repo.ID,
94-
})
95-
if err != nil {
96-
if upload.IsErrFileTypeForbidden(err) {
97-
log.Info("Skipping disallowed attachment type: %s", attachment.Name)
98-
continue
99-
}
100-
return err
85+
attachmentIDs := make([]string, 0, len(content.Attachments))
86+
if setting.Attachment.Enabled {
87+
for _, attachment := range content.Attachments {
88+
a, err := attachment_service.UploadAttachment(ctx, bytes.NewReader(attachment.Content), setting.Attachment.AllowedTypes, int64(len(attachment.Content)), &repo_model.Attachment{
89+
Name: attachment.Name,
90+
UploaderID: doer.ID,
91+
RepoID: issue.Repo.ID,
92+
})
93+
if err != nil {
94+
if upload.IsErrFileTypeForbidden(err) {
95+
log.Info("Skipping disallowed attachment type: %s", attachment.Name)
96+
continue
10197
}
102-
attachmentIDs = append(attachmentIDs, a.UUID)
98+
return err
10399
}
100+
attachmentIDs = append(attachmentIDs, a.UUID)
104101
}
102+
}
105103

106-
if content.Content == "" && len(attachmentIDs) == 0 {
107-
return nil
108-
}
104+
if content.Content == "" && len(attachmentIDs) == 0 {
105+
return nil
106+
}
109107

110-
_, err = issue_service.CreateIssueComment(ctx, doer, issue.Repo, issue, content.Content, attachmentIDs)
108+
switch r := ref.(type) {
109+
case *issues_model.Issue:
110+
_, err := issue_service.CreateIssueComment(ctx, doer, issue.Repo, issue, content.Content, attachmentIDs)
111111
if err != nil {
112112
return fmt.Errorf("CreateIssueComment failed: %w", err)
113113
}
114114
case *issues_model.Comment:
115115
comment := r
116116

117-
if content.Content == "" {
118-
return nil
119-
}
120-
121-
if comment.Type == issues_model.CommentTypeCode {
117+
switch comment.Type {
118+
case issues_model.CommentTypeCode:
122119
_, err := pull_service.CreateCodeComment(
123120
ctx,
124121
doer,
@@ -130,11 +127,16 @@ func (h *ReplyHandler) Handle(ctx context.Context, content *MailContent, doer *u
130127
false, // not pending review but a single review
131128
comment.ReviewID,
132129
"",
133-
nil,
130+
attachmentIDs,
134131
)
135132
if err != nil {
136133
return fmt.Errorf("CreateCodeComment failed: %w", err)
137134
}
135+
default:
136+
_, err := issue_service.CreateIssueComment(ctx, doer, issue.Repo, issue, content.Content, attachmentIDs)
137+
if err != nil {
138+
return fmt.Errorf("CreateIssueComment failed: %w", err)
139+
}
138140
}
139141
}
140142
return nil

services/packages/rpm/repository.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"errors"
1414
"fmt"
1515
"io"
16-
"net/url"
1716
"strings"
1817
"time"
1918

@@ -438,7 +437,7 @@ func buildPrimary(ctx context.Context, pv *packages_model.PackageVersion, pfs []
438437
Archive: pd.FileMetadata.ArchiveSize,
439438
},
440439
Location: Location{
441-
Href: fmt.Sprintf("package/%s/%s/%s/%s", url.PathEscape(pd.Package.Name), url.PathEscape(packageVersion), url.PathEscape(pd.FileMetadata.Architecture), url.PathEscape(fmt.Sprintf("%s-%s.%s.rpm", pd.Package.Name, packageVersion, pd.FileMetadata.Architecture))),
440+
Href: fmt.Sprintf("package/%s/%s/%s/%s-%s.%s.rpm", pd.Package.Name, packageVersion, pd.FileMetadata.Architecture, pd.Package.Name, packageVersion, pd.FileMetadata.Architecture),
442441
},
443442
Format: Format{
444443
License: pd.VersionMetadata.License,

templates/repo/tag/list.tmpl

+12-4
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@
44
<div class="ui container">
55
{{template "base/alert" .}}
66
{{template "repo/release_tag_header" .}}
7-
{{if .Releases}}
87
<h4 class="ui top attached header">
98
<div class="five wide column tw-flex tw-items-center">
10-
{{svg "octicon-tag" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.release.tags"}}
9+
{{.TagCount}} {{ctx.Locale.Tr "repo.release.tags"}}
1110
</div>
1211
</h4>
1312
{{$canReadReleases := $.Permission.CanRead ctx.Consts.RepoUnitTypeReleases}}
13+
<div class="ui attached segment">
14+
<form class="ignore-dirty" method="get">
15+
{{template "shared/search/combo" dict "Value" .Keyword "Placeholder" (ctx.Locale.Tr "search.tag_kind") "Tooltip" (ctx.Locale.Tr "search.tag_tooltip")}}
16+
</form>
17+
</div>
1418
<div class="ui attached table segment">
19+
{{if .Releases}}
1520
<table class="ui very basic striped fixed table single line" id="tags-table">
1621
<tbody class="tag-list">
1722
{{range $idx, $release := .Releases}}
@@ -57,9 +62,12 @@
5762
{{end}}
5863
</tbody>
5964
</table>
65+
{{else}}
66+
{{if .NumTags}}
67+
<p class="tw-p-4">{{ctx.Locale.Tr "no_results_found"}}</p>
68+
{{end}}
69+
{{end}}
6070
</div>
61-
{{end}}
62-
6371
{{template "base/paginate" .}}
6472
</div>
6573
</div>

0 commit comments

Comments
 (0)