Skip to content

Commit

Permalink
Merge remote-tracking branch 'giteaofficial/main'
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
zjjhot committed Sep 18, 2024
2 parents 55d51e2 + 55f1fcf commit 5a0b68b
Show file tree
Hide file tree
Showing 15 changed files with 230 additions and 188 deletions.
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ module code.gitea.io/gitea

go 1.23

// rfc5280 said: "The serial number is an integer assigned by the CA to each certificate."
// But some CAs use negative serial number, just relax the check. related:
// Default TLS cert uses negative serial number #895 https://github.com/microsoft/mssql-docker/issues/895
godebug x509negativeserial=1

require (
code.gitea.io/actions-proto-go v0.4.0
code.gitea.io/gitea-vet v0.2.3
Expand Down
6 changes: 6 additions & 0 deletions models/repo/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ type FindReleasesOptions struct {
IsDraft optional.Option[bool]
TagNames []string
HasSha1 optional.Option[bool] // useful to find draft releases which are created with existing tags
NamePattern optional.Option[string]
}

func (opts FindReleasesOptions) ToConds() builder.Cond {
Expand Down Expand Up @@ -261,6 +262,11 @@ func (opts FindReleasesOptions) ToConds() builder.Cond {
cond = cond.And(builder.Eq{"sha1": ""})
}
}

if opts.NamePattern.Has() && opts.NamePattern.Value() != "" {
cond = cond.And(builder.Like{"lower_tag_name", strings.ToLower(opts.NamePattern.Value())})
}

return cond
}

Expand Down
2 changes: 1 addition & 1 deletion modules/templates/util_avatar.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func AvatarHTML(src string, size int, class, name string) template.HTML {
name = "avatar"
}

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

// Avatar renders user avatars. args: user, size (int), class (string)
Expand Down
4 changes: 3 additions & 1 deletion options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ filter.public = Public
filter.private = Private

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

[search]
search = Search...
Expand All @@ -177,6 +178,8 @@ code_search_by_git_grep = Current code search results are provided by "git grep"
package_kind = Search packages...
project_kind = Search projects...
branch_kind = Search branches...
tag_kind = Search tags...
tag_tooltip = Search for matching tags. Use '%' to match any sequence of numbers.
commit_kind = Search commits...
runner_kind = Search runners...
no_results = No matching results found.
Expand Down Expand Up @@ -1279,7 +1282,6 @@ commit_graph.color = Color
commit.contained_in = This commit is contained in:
commit.contained_in_default_branch = This commit is part of the default branch
commit.load_referencing_branches_and_tags = Load branches and tags referencing this commit
commit.load_tags_failed = Load tags failed because of internal error
blame = Blame
download_file = Download file
normal_view = Normal View
Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_fr-FR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,6 @@ commit_graph.color=Couleur
commit.contained_in=Cette révision appartient à :
commit.contained_in_default_branch=Cette révision appartient à la branche par défaut
commit.load_referencing_branches_and_tags=Charger les branches et étiquettes référençant cette révision
commit.load_tags_failed=Le chargement des étiquettes a échoué à cause d’une erreur interne
blame=Annotations
download_file=Télécharger le fichier
normal_view=Vue normale
Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_ja-JP.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,6 @@ commit_graph.color=カラー
commit.contained_in=このコミットが含まれているのは:
commit.contained_in_default_branch=このコミットはデフォルトブランチに含まれています
commit.load_referencing_branches_and_tags=このコミットを参照しているブランチやタグを取得
commit.load_tags_failed=内部エラーによりタグの読み込みに失敗しました
blame=Blame
download_file=ファイルをダウンロード
normal_view=通常表示
Expand Down
2 changes: 1 addition & 1 deletion options/locale/locale_pt-PT.ini
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ filter.public=Público
filter.private=Privado

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

[search]
search=Pesquisar...
Expand Down Expand Up @@ -1279,7 +1280,6 @@ commit_graph.color=Colorido
commit.contained_in=Este cometimento está contido em:
commit.contained_in_default_branch=Este cometimento é parte do ramo principal
commit.load_referencing_branches_and_tags=Carregar ramos e etiquetas que referenciem este cometimento
commit.load_tags_failed=O carregamento das etiquetas falhou por causa de um erro interno
blame=Responsabilidade
download_file=Descarregar ficheiro
normal_view=Vista normal
Expand Down
14 changes: 10 additions & 4 deletions routers/api/v1/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,10 +833,16 @@ func EditIssue(ctx *context.APIContext) {
if (form.Deadline != nil || form.RemoveDeadline != nil) && canWrite {
var deadlineUnix timeutil.TimeStamp

if (form.RemoveDeadline == nil || !*form.RemoveDeadline) && !form.Deadline.IsZero() {
deadline := time.Date(form.Deadline.Year(), form.Deadline.Month(), form.Deadline.Day(),
23, 59, 59, 0, form.Deadline.Location())
deadlineUnix = timeutil.TimeStamp(deadline.Unix())
if form.RemoveDeadline == nil || !*form.RemoveDeadline {
if form.Deadline == nil {
ctx.Error(http.StatusBadRequest, "", "The due_date cannot be empty")
return
}
if !form.Deadline.IsZero() {
deadline := time.Date(form.Deadline.Year(), form.Deadline.Month(), form.Deadline.Day(),
23, 59, 59, 0, form.Deadline.Location())
deadlineUnix = timeutil.TimeStamp(deadline.Unix())
}
}

if err := issues_model.UpdateIssueDeadline(ctx, issue, deadlineUnix, ctx.Doer); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion routers/web/repo/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func Commits(ctx *context.Context) {
commitsTagsMap, err := repo_model.FindTagsByCommitIDs(ctx, ctx.Repo.Repository.ID, commitIDs...)
if err != nil {
log.Error("FindTagsByCommitIDs: %v", err)
ctx.Flash.Error(ctx.Tr("repo.commit.load_tags_failed"))
ctx.Flash.Error(ctx.Tr("internal_error_skipped", "FindTagsByCommitIDs"))
} else {
ctx.Data["CommitsTagsMap"] = commitsTagsMap
}
Expand Down
16 changes: 13 additions & 3 deletions routers/web/repo/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ func TagsList(ctx *context.Context) {
ctx.Data["HideBranchesInDropdown"] = true
ctx.Data["CanCreateRelease"] = ctx.Repo.CanWrite(unit.TypeReleases) && !ctx.Repo.Repository.IsArchived

namePattern := ctx.FormTrim("q")

listOptions := db.ListOptions{
Page: ctx.FormInt("page"),
PageSize: ctx.FormInt("limit"),
Expand All @@ -233,6 +235,7 @@ func TagsList(ctx *context.Context) {
IncludeTags: true,
HasSha1: optional.Some(true),
RepoID: ctx.Repo.Repository.ID,
NamePattern: optional.Some(namePattern),
}

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

count, err := db.Count[repo_model.Release](ctx, opts)
if err != nil {
ctx.ServerError("GetReleasesByRepoID", err)
return
}

ctx.Data["Keyword"] = namePattern
ctx.Data["Releases"] = releases
ctx.Data["TagCount"] = count

numTags := ctx.Data["NumTags"].(int64)
pager := context.NewPagination(int(numTags), opts.PageSize, opts.Page, 5)
pager := context.NewPagination(int(count), opts.PageSize, opts.Page, 5)
pager.SetDefaultParams(ctx)
ctx.Data["Page"] = pager

ctx.Data["PageIsViewCode"] = !ctx.Repo.Repository.UnitEnabled(ctx, unit.TypeReleases)

ctx.HTML(http.StatusOK, tplTagsList)
}

Expand Down
56 changes: 29 additions & 27 deletions services/mailer/incoming/incoming_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,43 +82,40 @@ func (h *ReplyHandler) Handle(ctx context.Context, content *MailContent, doer *u
return nil
}

switch r := ref.(type) {
case *issues_model.Issue:
attachmentIDs := make([]string, 0, len(content.Attachments))
if setting.Attachment.Enabled {
for _, attachment := range content.Attachments {
a, err := attachment_service.UploadAttachment(ctx, bytes.NewReader(attachment.Content), setting.Attachment.AllowedTypes, int64(len(attachment.Content)), &repo_model.Attachment{
Name: attachment.Name,
UploaderID: doer.ID,
RepoID: issue.Repo.ID,
})
if err != nil {
if upload.IsErrFileTypeForbidden(err) {
log.Info("Skipping disallowed attachment type: %s", attachment.Name)
continue
}
return err
attachmentIDs := make([]string, 0, len(content.Attachments))
if setting.Attachment.Enabled {
for _, attachment := range content.Attachments {
a, err := attachment_service.UploadAttachment(ctx, bytes.NewReader(attachment.Content), setting.Attachment.AllowedTypes, int64(len(attachment.Content)), &repo_model.Attachment{
Name: attachment.Name,
UploaderID: doer.ID,
RepoID: issue.Repo.ID,
})
if err != nil {
if upload.IsErrFileTypeForbidden(err) {
log.Info("Skipping disallowed attachment type: %s", attachment.Name)
continue
}
attachmentIDs = append(attachmentIDs, a.UUID)
return err
}
attachmentIDs = append(attachmentIDs, a.UUID)
}
}

if content.Content == "" && len(attachmentIDs) == 0 {
return nil
}
if content.Content == "" && len(attachmentIDs) == 0 {
return nil
}

_, err = issue_service.CreateIssueComment(ctx, doer, issue.Repo, issue, content.Content, attachmentIDs)
switch r := ref.(type) {
case *issues_model.Issue:
_, err := issue_service.CreateIssueComment(ctx, doer, issue.Repo, issue, content.Content, attachmentIDs)
if err != nil {
return fmt.Errorf("CreateIssueComment failed: %w", err)
}
case *issues_model.Comment:
comment := r

if content.Content == "" {
return nil
}

if comment.Type == issues_model.CommentTypeCode {
switch comment.Type {
case issues_model.CommentTypeCode:
_, err := pull_service.CreateCodeComment(
ctx,
doer,
Expand All @@ -130,11 +127,16 @@ func (h *ReplyHandler) Handle(ctx context.Context, content *MailContent, doer *u
false, // not pending review but a single review
comment.ReviewID,
"",
nil,
attachmentIDs,
)
if err != nil {
return fmt.Errorf("CreateCodeComment failed: %w", err)
}
default:
_, err := issue_service.CreateIssueComment(ctx, doer, issue.Repo, issue, content.Content, attachmentIDs)
if err != nil {
return fmt.Errorf("CreateIssueComment failed: %w", err)
}
}
}
return nil
Expand Down
3 changes: 1 addition & 2 deletions services/packages/rpm/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"errors"
"fmt"
"io"
"net/url"
"strings"
"time"

Expand Down Expand Up @@ -438,7 +437,7 @@ func buildPrimary(ctx context.Context, pv *packages_model.PackageVersion, pfs []
Archive: pd.FileMetadata.ArchiveSize,
},
Location: Location{
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))),
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),
},
Format: Format{
License: pd.VersionMetadata.License,
Expand Down
16 changes: 12 additions & 4 deletions templates/repo/tag/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@
<div class="ui container">
{{template "base/alert" .}}
{{template "repo/release_tag_header" .}}
{{if .Releases}}
<h4 class="ui top attached header">
<div class="five wide column tw-flex tw-items-center">
{{svg "octicon-tag" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.release.tags"}}
{{.TagCount}} {{ctx.Locale.Tr "repo.release.tags"}}
</div>
</h4>
{{$canReadReleases := $.Permission.CanRead ctx.Consts.RepoUnitTypeReleases}}
<div class="ui attached segment">
<form class="ignore-dirty" method="get">
{{template "shared/search/combo" dict "Value" .Keyword "Placeholder" (ctx.Locale.Tr "search.tag_kind") "Tooltip" (ctx.Locale.Tr "search.tag_tooltip")}}
</form>
</div>
<div class="ui attached table segment">
{{if .Releases}}
<table class="ui very basic striped fixed table single line" id="tags-table">
<tbody class="tag-list">
{{range $idx, $release := .Releases}}
Expand Down Expand Up @@ -57,9 +62,12 @@
{{end}}
</tbody>
</table>
{{else}}
{{if .NumTags}}
<p class="tw-p-4">{{ctx.Locale.Tr "no_results_found"}}</p>
{{end}}
{{end}}
</div>
{{end}}

{{template "base/paginate" .}}
</div>
</div>
Expand Down
Loading

0 comments on commit 5a0b68b

Please sign in to comment.