From bffbf08f26656c2c073da2a989f3abc38fdbb444 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 3 Dec 2023 12:22:44 +0100 Subject: [PATCH 001/480] Fix missing issue search index update when changing status (#28325) Changing an issue status, assignee, labels or milestone without also adding a comment would not update the index, resulting in wrong search results. --- services/indexer/notify.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/services/indexer/notify.go b/services/indexer/notify.go index e0b87faedbf..f1e21a2d40e 100644 --- a/services/indexer/notify.go +++ b/services/indexer/notify.go @@ -130,3 +130,25 @@ func (r *indexerNotifier) IssueChangeTitle(ctx context.Context, doer *user_model func (r *indexerNotifier) IssueChangeRef(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldRef string) { issue_indexer.UpdateIssueIndexer(ctx, issue.ID) } + +func (r *indexerNotifier) IssueChangeStatus(ctx context.Context, doer *user_model.User, commitID string, issue *issues_model.Issue, actionComment *issues_model.Comment, closeOrReopen bool) { + issue_indexer.UpdateIssueIndexer(ctx, issue.ID) +} + +func (r *indexerNotifier) IssueChangeAssignee(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, assignee *user_model.User, removed bool, comment *issues_model.Comment) { + issue_indexer.UpdateIssueIndexer(ctx, issue.ID) +} + +func (r *indexerNotifier) IssueChangeMilestone(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldMilestoneID int64) { + issue_indexer.UpdateIssueIndexer(ctx, issue.ID) +} + +func (r *indexerNotifier) IssueChangeLabels(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, + addedLabels, removedLabels []*issues_model.Label, +) { + issue_indexer.UpdateIssueIndexer(ctx, issue.ID) +} + +func (r *indexerNotifier) IssueClearLabels(ctx context.Context, doer *user_model.User, issue *issues_model.Issue) { + issue_indexer.UpdateIssueIndexer(ctx, issue.ID) +} From ec1feedbf582b05b6a5e8c59fb2457f25d053ba2 Mon Sep 17 00:00:00 2001 From: GiteaBot Date: Mon, 4 Dec 2023 00:25:15 +0000 Subject: [PATCH 002/480] [skip ci] Updated licenses and gitignores --- options/license/SAX-PD-2.0 | 10 ++++++++++ options/license/radvd | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 options/license/SAX-PD-2.0 create mode 100644 options/license/radvd diff --git a/options/license/SAX-PD-2.0 b/options/license/SAX-PD-2.0 new file mode 100644 index 00000000000..b329db3bb50 --- /dev/null +++ b/options/license/SAX-PD-2.0 @@ -0,0 +1,10 @@ +SAX2 is Free! + +I hereby abandon any property rights to SAX 2.0 (the Simple API for +XML), and release all of the SAX 2.0 source code, compiled code, and +documentation contained in this distribution into the Public Domain. +SAX comes with NO WARRANTY or guarantee of fitness for any +purpose. + +David Megginson, david@megginson.com +2000-05-05 diff --git a/options/license/radvd b/options/license/radvd new file mode 100644 index 00000000000..4e77909ed75 --- /dev/null +++ b/options/license/radvd @@ -0,0 +1,37 @@ + The author(s) grant permission for redistribution and use in source and +binary forms, with or without modification, of the software and documentation +provided that the following conditions are met: + +0. If you receive a version of the software that is specifically labelled + as not being for redistribution (check the version message and/or README), + you are not permitted to redistribute that version of the software in any + way or form. +1. All terms of all other applicable copyrights and licenses must be + followed. +2. Redistributions of source code must retain the authors' copyright + notice(s), this list of conditions, and the following disclaimer. +3. Redistributions in binary form must reproduce the authors' copyright + notice(s), this list of conditions, and the following disclaimer in the + documentation and/or other materials provided with the distribution. +4. All advertising materials mentioning features or use of this software + must display the following acknowledgement with the name(s) of the + authors as specified in the copyright notice(s) substituted where + indicated: + + This product includes software developed by the authors which are + mentioned at the start of the source files and other contributors. + +5. Neither the name(s) of the author(s) nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS ``AS IS'' AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. From b3c258828f11d6c5900f8209a46ea93482c93519 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Mon, 4 Dec 2023 22:48:42 +0100 Subject: [PATCH 003/480] Refactor template empty checks (#28351) --- templates/repo/actions/runs_list.tmpl | 2 +- templates/repo/diff/section_split.tmpl | 22 +++++++++---------- templates/repo/diff/section_unified.tmpl | 2 +- templates/repo/header.tmpl | 6 ++--- templates/repo/issue/filters.tmpl | 2 +- .../repo/issue/view_content/sidebar.tmpl | 2 +- templates/shared/issuelist.tmpl | 2 +- templates/user/dashboard/feeds.tmpl | 2 +- .../user/notification/notification_div.tmpl | 2 +- .../notification_subscriptions.tmpl | 2 +- templates/user/settings/keys_gpg.tmpl | 2 +- 11 files changed, 23 insertions(+), 23 deletions(-) diff --git a/templates/repo/actions/runs_list.tmpl b/templates/repo/actions/runs_list.tmpl index 3b289fb68f2..580fb08a9ee 100644 --- a/templates/repo/actions/runs_list.tmpl +++ b/templates/repo/actions/runs_list.tmpl @@ -1,5 +1,5 @@
- {{if eq (len .Runs) 0}} + {{if not .Runs}}
{{svg "octicon-no-entry" 48}}

{{if $.IsFiltered}}{{ctx.Locale.Tr "actions.runs.no_results"}}{{else}}{{ctx.Locale.Tr "actions.runs.no_runs"}}{{end}}

diff --git a/templates/repo/diff/section_split.tmpl b/templates/repo/diff/section_split.tmpl index 94dea4ac411..5b0d982e96f 100644 --- a/templates/repo/diff/section_split.tmpl +++ b/templates/repo/diff/section_split.tmpl @@ -108,25 +108,27 @@ {{if and (eq .GetType 3) $hasmatch}} {{$match := index $section.Lines $line.Match}} - {{if or (gt (len $line.Comments) 0) (gt (len $match.Comments) 0)}} + {{if or $line.Comments $match.Comments}} - {{if gt (len $line.Comments) 0}} + {{if $line.Comments}} {{if eq $line.GetCommentSide "previous"}} {{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}} {{end}} {{end}} - {{if gt (len $match.Comments) 0}} + {{if $match.Comments}} {{if eq $match.GetCommentSide "previous"}} {{template "repo/diff/conversation" dict "." $.root "comments" $match.Comments}} {{end}} {{end}} - {{if eq $line.GetCommentSide "proposed"}} - {{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}} + {{if $line.Comments}} + {{if eq $line.GetCommentSide "proposed"}} + {{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}} + {{end}} {{end}} - {{if gt (len $match.Comments) 0}} + {{if $match.Comments}} {{if eq $match.GetCommentSide "proposed"}} {{template "repo/diff/conversation" dict "." $.root "comments" $match.Comments}} {{end}} @@ -134,13 +136,11 @@ {{end}} - {{else if gt (len $line.Comments) 0}} + {{else if $line.Comments}} - {{if gt (len $line.Comments) 0}} - {{if eq $line.GetCommentSide "previous"}} - {{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}} - {{end}} + {{if eq $line.GetCommentSide "previous"}} + {{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}} {{end}} diff --git a/templates/repo/diff/section_unified.tmpl b/templates/repo/diff/section_unified.tmpl index d2345c3b88e..2b901411e29 100644 --- a/templates/repo/diff/section_unified.tmpl +++ b/templates/repo/diff/section_unified.tmpl @@ -60,7 +60,7 @@ */}} {{end}} - {{if gt (len $line.Comments) 0}} + {{if $line.Comments}} {{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}} diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index f306435409e..2a3ebc4e772 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -81,12 +81,12 @@ {{end}} {{if and (not .IsEmpty) ($.Permission.CanRead $.UnitTypeCode)}}
@@ -98,7 +98,7 @@ href="{{AppSubUrl}}/{{(index $.UserAndOrgForks 0).FullName}}" {{/*else is not required here, because the button shouldn't link to any site if you can't create a fork*/}} {{end}} - {{else if eq (len $.UserAndOrgForks) 0}} + {{else if not $.UserAndOrgForks}} href="{{AppSubUrl}}/repo/fork/{{.ID}}" {{else}} data-modal="#fork-repo-modal" diff --git a/templates/repo/issue/filters.tmpl b/templates/repo/issue/filters.tmpl index 1d200e23b7a..56c65e24014 100644 --- a/templates/repo/issue/filters.tmpl +++ b/templates/repo/issue/filters.tmpl @@ -1,6 +1,6 @@
- {{if and ($.CanWriteIssuesOrPulls) (gt (len .Issues) 0)}} + {{if and $.CanWriteIssuesOrPulls .Issues}} {{end}} {{template "repo/issue/openclose" .}} diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index 4be1f52dd5c..c81cc5c10a6 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -339,7 +339,7 @@
{{end}} - {{if gt (len .WorkingUsers) 0}} + {{if .WorkingUsers}}
{{ctx.Locale.Tr "repo.issues.time_spent_from_all_authors" ($.Issue.TotalTrackedTime | Sec2Time) | Safe}} diff --git a/templates/shared/issuelist.tmpl b/templates/shared/issuelist.tmpl index e0d2e102e5e..7fd1f4e0f8d 100644 --- a/templates/shared/issuelist.tmpl +++ b/templates/shared/issuelist.tmpl @@ -140,7 +140,7 @@ {{ctx.Locale.TrN $waitingOfficial "repo.pulls.waiting_count_1" "repo.pulls.waiting_count_n" $waitingOfficial}} {{end}} - {{if and (not .PullRequest.HasMerged) (gt (len .PullRequest.ConflictedFiles) 0)}} + {{if and (not .PullRequest.HasMerged) .PullRequest.ConflictedFiles}} {{svg "octicon-x" 14}} {{ctx.Locale.TrN (len .PullRequest.ConflictedFiles) "repo.pulls.num_conflicting_files_1" "repo.pulls.num_conflicting_files_n" (len .PullRequest.ConflictedFiles)}} diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl index 3a080a3505a..728715bbc75 100644 --- a/templates/user/dashboard/feeds.tmpl +++ b/templates/user/dashboard/feeds.tmpl @@ -106,7 +106,7 @@ {{else if .GetOpType.InActions "comment_issue" "approve_pull_request" "reject_pull_request" "comment_pull"}} {{(.GetIssueTitle ctx) | RenderEmoji $.Context | RenderCodeBlock}} {{$comment := index .GetIssueInfos 1}} - {{if gt (len $comment) 0}} + {{if $comment}}
{{RenderMarkdownToHtml ctx $comment}}
{{end}} {{else if .GetOpType.InActions "merge_pull_request"}} diff --git a/templates/user/notification/notification_div.tmpl b/templates/user/notification/notification_div.tmpl index e98eff9cffb..d8f8d462d35 100644 --- a/templates/user/notification/notification_div.tmpl +++ b/templates/user/notification/notification_div.tmpl @@ -24,7 +24,7 @@
- {{if eq (len .Notifications) 0}} + {{if not .Notifications}}
{{svg "octicon-inbox" 56 "gt-mb-4"}} {{if eq .Status 1}} diff --git a/templates/user/notification/notification_subscriptions.tmpl b/templates/user/notification/notification_subscriptions.tmpl index 7eb4c8ea446..ec40d3afeaf 100644 --- a/templates/user/notification/notification_subscriptions.tmpl +++ b/templates/user/notification/notification_subscriptions.tmpl @@ -63,7 +63,7 @@
- {{if eq (len .Issues) 0}} + {{if not .Issues}} {{ctx.Locale.Tr "notification.no_subscriptions"}} {{else}} {{template "shared/issuelist" dict "." . "listType" "dashboard"}} diff --git a/templates/user/settings/keys_gpg.tmpl b/templates/user/settings/keys_gpg.tmpl index bd560fa325f..481d7482b49 100644 --- a/templates/user/settings/keys_gpg.tmpl +++ b/templates/user/settings/keys_gpg.tmpl @@ -55,7 +55,7 @@ {{if .Verified}} {{svg "octicon-verified"}} {{ctx.Locale.Tr "settings.gpg_key_verified"}} {{end}} - {{if gt (len .Emails) 0}} + {{if .Emails}} {{svg "octicon-mail"}} {{ctx.Locale.Tr "settings.gpg_key_matched_identities"}} {{range .Emails}}{{.Email}} {{end}} {{end}}
From dfa77ac0205d53ac6de45e25c13e122592739bd4 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Tue, 5 Dec 2023 01:48:01 +0100 Subject: [PATCH 004/480] Fix RPM/Debian signature key creation (#28352) Fixes #28324 The name parameter can't contain some characters (https://github.com/keybase/go-crypto/blob/master/openpgp/keys.go#L680) but is optional. Therefore just use an empty string. --- services/packages/debian/repository.go | 2 +- services/packages/rpm/repository.go | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/services/packages/debian/repository.go b/services/packages/debian/repository.go index cbde53f9611..fca3cf42032 100644 --- a/services/packages/debian/repository.go +++ b/services/packages/debian/repository.go @@ -67,7 +67,7 @@ func GetOrCreateKeyPair(ctx context.Context, ownerID int64) (string, string, err } func generateKeypair() (string, string, error) { - e, err := openpgp.NewEntity(setting.AppName, "Debian Registry", "", nil) + e, err := openpgp.NewEntity("", "Debian Registry", "", nil) if err != nil { return "", "", err } diff --git a/services/packages/rpm/repository.go b/services/packages/rpm/repository.go index 1d0dc83cae8..c9db0247f6d 100644 --- a/services/packages/rpm/repository.go +++ b/services/packages/rpm/repository.go @@ -22,7 +22,6 @@ import ( "code.gitea.io/gitea/modules/json" packages_module "code.gitea.io/gitea/modules/packages" rpm_module "code.gitea.io/gitea/modules/packages/rpm" - "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" packages_service "code.gitea.io/gitea/services/packages" @@ -68,7 +67,7 @@ func GetOrCreateKeyPair(ctx context.Context, ownerID int64) (string, string, err } func generateKeypair() (string, string, error) { - e, err := openpgp.NewEntity(setting.AppName, "RPM Registry", "", nil) + e, err := openpgp.NewEntity("", "RPM Registry", "", nil) if err != nil { return "", "", err } @@ -126,7 +125,7 @@ type packageData struct { type packageCache = map[*packages_model.PackageFile]*packageData -// BuildSpecificRepositoryFiles builds metadata files for the repository +// BuildRepositoryFiles builds metadata files for the repository func BuildRepositoryFiles(ctx context.Context, ownerID int64) error { pv, err := GetOrCreateRepositoryVersion(ctx, ownerID) if err != nil { From 38a93a0665456d0cfc9569946a1f6164835b6aea Mon Sep 17 00:00:00 2001 From: darrinsmart Date: Mon, 4 Dec 2023 22:34:24 -0800 Subject: [PATCH 005/480] Convert git commit summary to valid UTF8. (#28356) The summary string ends up in the database, and (at least) MySQL & PostgreSQL require valid UTF8 strings. Fixes #28178 Co-authored-by: Darrin Smart --- modules/git/commit.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/git/commit.go b/modules/git/commit.go index b09be25ba09..4ff8f6148f7 100644 --- a/modules/git/commit.go +++ b/modules/git/commit.go @@ -43,8 +43,9 @@ func (c *Commit) Message() string { } // Summary returns first line of commit message. +// The string is forced to be valid UTF8 func (c *Commit) Summary() string { - return strings.Split(strings.TrimSpace(c.CommitMessage), "\n")[0] + return strings.ToValidUTF8(strings.Split(strings.TrimSpace(c.CommitMessage), "\n")[0], "?") } // ParentID returns oid of n-th parent (0-based index). From 0aab2d38a7d91bc8caff332e452364468ce52d9a Mon Sep 17 00:00:00 2001 From: Nanguan Lin <70063547+lng2020@users.noreply.github.com> Date: Tue, 5 Dec 2023 15:30:43 +0800 Subject: [PATCH 006/480] Remove deprecated query condition in ListReleases (#28339) close #24057 call stack: https://github.com/go-gitea/gitea/blob/25faee3c5f5be23c99b3b7e50418fc0dbad7a41b/routers/api/v1/repo/release.go#L154 https://github.com/go-gitea/gitea/blob/ec1feedbf582b05b6a5e8c59fb2457f25d053ba2/routers/api/v1/utils/page.go#L13-L18 https://github.com/go-gitea/gitea/blob/ec1feedbf582b05b6a5e8c59fb2457f25d053ba2/services/convert/utils.go#L15-L22 ## :warning: Breaking :warning: (though it's not caused by this PR) Do not use `per_page` to specify pagination; use `limit` instead --- routers/api/v1/repo/release.go | 8 -------- templates/swagger/v1_json.tmpl | 6 ------ 2 files changed, 14 deletions(-) diff --git a/routers/api/v1/repo/release.go b/routers/api/v1/repo/release.go index 6c70bffca33..b1d3b5f4571 100644 --- a/routers/api/v1/repo/release.go +++ b/routers/api/v1/repo/release.go @@ -133,11 +133,6 @@ func ListReleases(ctx *context.APIContext) { // in: query // description: filter (exclude / include) pre-releases // type: boolean - // - name: per_page - // in: query - // description: page size of results, deprecated - use limit - // type: integer - // deprecated: true // - name: page // in: query // description: page number of results to return (1-based) @@ -152,9 +147,6 @@ func ListReleases(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" listOptions := utils.GetListOptions(ctx) - if listOptions.PageSize == 0 && ctx.FormInt("per_page") != 0 { - listOptions.PageSize = ctx.FormInt("per_page") - } opts := repo_model.FindReleasesOptions{ ListOptions: listOptions, diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index d32684c1af3..2541726a64b 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -11728,12 +11728,6 @@ "name": "pre-release", "in": "query" }, - { - "type": "integer", - "description": "page size of results, deprecated - use limit", - "name": "per_page", - "in": "query" - }, { "type": "integer", "description": "page number of results to return (1-based)", From a95d5b7702e37488e90c3e02016ab91f0c8b5153 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Tue, 5 Dec 2023 09:01:02 +0100 Subject: [PATCH 007/480] Add `HEAD` support for rpm repo files (#28309) Fixes https://codeberg.org/forgejo/forgejo/issues/1810 zypper uses HEAD requests to check file existence. https://github.com/openSUSE/libzypp/blob/HEAD/zypp/RepoManager.cc#L2549 https://github.com/openSUSE/libzypp/blob/HEAD/zypp-curl/ng/network/private/downloaderstates/basicdownloader_p.cc#L116 @ExplodingDragon fyi --- routers/api/packages/api.go | 5 ++++- routers/api/packages/rpm/rpm.go | 24 ++++++++++++++++++++++ tests/integration/api_packages_rpm_test.go | 8 +++++++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/routers/api/packages/api.go b/routers/api/packages/api.go index 2ba35e21380..722ee3f87b1 100644 --- a/routers/api/packages/api.go +++ b/routers/api/packages/api.go @@ -520,7 +520,10 @@ func CommonRoutes() *web.Route { r.Get("", rpm.DownloadPackageFile) r.Delete("", reqPackageAccess(perm.AccessModeWrite), rpm.DeletePackageFile) }) - r.Get("/repodata/{filename}", rpm.GetRepositoryFile) + r.Group("/repodata/{filename}", func() { + r.Head("", rpm.CheckRepositoryFileExistence) + r.Get("", rpm.GetRepositoryFile) + }) }, reqPackageAccess(perm.AccessModeRead)) r.Group("/rubygems", func() { r.Get("/specs.4.8.gz", rubygems.EnumeratePackages) diff --git a/routers/api/packages/rpm/rpm.go b/routers/api/packages/rpm/rpm.go index f5d8b67e16d..2e161940b8c 100644 --- a/routers/api/packages/rpm/rpm.go +++ b/routers/api/packages/rpm/rpm.go @@ -57,6 +57,30 @@ func GetRepositoryKey(ctx *context.Context) { }) } +func CheckRepositoryFileExistence(ctx *context.Context) { + pv, err := rpm_service.GetOrCreateRepositoryVersion(ctx, ctx.Package.Owner.ID) + if err != nil { + apiError(ctx, http.StatusInternalServerError, err) + return + } + + pf, err := packages_model.GetFileForVersionByName(ctx, pv.ID, ctx.Params("filename"), packages_model.EmptyFileKey) + if err != nil { + if errors.Is(err, util.ErrNotExist) { + ctx.Status(http.StatusNotFound) + } else { + apiError(ctx, http.StatusInternalServerError, err) + } + return + } + + ctx.SetServeHeaders(&context.ServeHeaderOptions{ + Filename: pf.Name, + LastModified: pf.CreatedUnix.AsLocalTime(), + }) + ctx.Status(http.StatusOK) +} + // Gets a pre-generated repository metadata file func GetRepositoryFile(ctx *context.Context) { pv, err := rpm_service.GetOrCreateRepositoryVersion(ctx, ctx.Package.Owner.ID) diff --git a/tests/integration/api_packages_rpm_test.go b/tests/integration/api_packages_rpm_test.go index fc4c4d1c4b6..6d3b0688f2a 100644 --- a/tests/integration/api_packages_rpm_test.go +++ b/tests/integration/api_packages_rpm_test.go @@ -149,12 +149,18 @@ gpgkey=%sapi/packages/%s/rpm/repository.key`, user.Name, user.Name, setting.AppN url := rootURL + "/repodata" - req := NewRequest(t, "GET", url+"/dummy.xml") + req := NewRequest(t, "HEAD", url+"/dummy.xml") + MakeRequest(t, req, http.StatusNotFound) + + req = NewRequest(t, "GET", url+"/dummy.xml") MakeRequest(t, req, http.StatusNotFound) t.Run("repomd.xml", func(t *testing.T) { defer tests.PrintCurrentTest(t)() + req = NewRequest(t, "HEAD", url+"/repomd.xml") + MakeRequest(t, req, http.StatusOK) + req = NewRequest(t, "GET", url+"/repomd.xml") resp := MakeRequest(t, req, http.StatusOK) From 49b98e45bc6301b74181282a410aa02d8e0b8f30 Mon Sep 17 00:00:00 2001 From: Nanguan Lin <70063547+lng2020@users.noreply.github.com> Date: Tue, 5 Dec 2023 16:29:43 +0800 Subject: [PATCH 008/480] Fix migration panic due to an empty review comment diff (#28334) Fix #28328 ``` func (p *PullRequestComment) GetDiffHunk() string { if p == nil || p.DiffHunk == nil { return "" } return *p.DiffHunk } ``` This function in the package `go-github` may return an empty diff. When it's empty, the following code will panic because it access `ss[1]` https://github.com/go-gitea/gitea/blob/ec1feedbf582b05b6a5e8c59fb2457f25d053ba2/services/migrations/gitea_uploader.go#L861-L867 https://github.com/go-gitea/gitea/blob/ec1feedbf582b05b6a5e8c59fb2457f25d053ba2/modules/git/diff.go#L97-L101 --- services/migrations/gitea_uploader.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/migrations/gitea_uploader.go b/services/migrations/gitea_uploader.go index ddc2cbd4ec8..6ad0a2326bd 100644 --- a/services/migrations/gitea_uploader.go +++ b/services/migrations/gitea_uploader.go @@ -862,7 +862,7 @@ func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error { line := comment.Line if line != 0 { comment.Position = 1 - } else { + } else if comment.DiffHunk != "" { _, _, line, _ = git.ParseDiffHunkString(comment.DiffHunk) } From f891172ef4163bf75ebe00a9e76a4ab60f0d3d4a Mon Sep 17 00:00:00 2001 From: Nate Levesque Date: Tue, 5 Dec 2023 09:31:13 -0500 Subject: [PATCH 009/480] handle repository.size column being NULL in migration v263 (#28336) This resolves a problem I encountered while updating gitea from 1.20.4 to 1.21. For some reason (correct or otherwise) there are some values in `repository.size` that are NULL in my gitea database which cause this migration to fail due to the NOT NULL constraints. Log snippet (excuse the escape characters) ``` ESC[36mgitea |ESC[0m 2023-12-04T03:52:28.573122395Z 2023/12/04 03:52:28 ...ations/migrations.go:641:Migrate() [I] Migration[263]: Add git_size and lfs_size columns to repository table ESC[36mgitea |ESC[0m 2023-12-04T03:52:28.608705544Z 2023/12/04 03:52:28 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #3/10 failed. Error: migrate: migration[263]: Add git_size and lfs_size columns to repository table failed: NOT NULL constraint failed: repository.git_size ``` I assume this should be reasonably safe since `repository.git_size` has a default value of 0 but I don't know if that value being 0 in the odd situation where `repository.size == NULL` has any problematic consequences. --- models/migrations/v1_21/v263.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/models/migrations/v1_21/v263.go b/models/migrations/v1_21/v263.go index 5dccd8bfa0d..2c7cbadf0d8 100644 --- a/models/migrations/v1_21/v263.go +++ b/models/migrations/v1_21/v263.go @@ -32,7 +32,12 @@ func AddGitSizeAndLFSSizeToRepositoryTable(x *xorm.Engine) error { return err } - _, err = sess.Exec(`UPDATE repository SET git_size = size - lfs_size`) + _, err = sess.Exec(`UPDATE repository SET size = 0 WHERE size IS NULL`) + if err != nil { + return err + } + + _, err = sess.Exec(`UPDATE repository SET git_size = size - lfs_size WHERE size > lfs_size`) if err != nil { return err } From 876a0cb3d652f42545abdb33dc4fd71a7c3343bf Mon Sep 17 00:00:00 2001 From: Earl Warren <109468362+earl-warren@users.noreply.github.com> Date: Tue, 5 Dec 2023 16:02:01 +0100 Subject: [PATCH 010/480] Render PyPi long description as document (#28272) Co-authored-by: Gusted --- modules/templates/util_render.go | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/templates/util_render.go b/modules/templates/util_render.go index 84c3a1587af..8621a371bd5 100644 --- a/modules/templates/util_render.go +++ b/modules/templates/util_render.go @@ -230,6 +230,7 @@ func RenderMarkdownToHtml(ctx context.Context, input string) template.HTML { //n output, err := markdown.RenderString(&markup.RenderContext{ Ctx: ctx, URLPrefix: setting.AppSubURL, + Metas: map[string]string{"mode": "document"}, }, input) if err != nil { log.Error("RenderString: %v", err) From c81255ba4e6c6396e02d00513ebe402b15c4346b Mon Sep 17 00:00:00 2001 From: GiteaBot Date: Wed, 6 Dec 2023 00:25:02 +0000 Subject: [PATCH 011/480] [skip ci] Updated translations via Crowdin --- options/locale/locale_pt-PT.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options/locale/locale_pt-PT.ini b/options/locale/locale_pt-PT.ini index 9d9c5eada1c..b3c60333698 100644 --- a/options/locale/locale_pt-PT.ini +++ b/options/locale/locale_pt-PT.ini @@ -3305,7 +3305,7 @@ error.unit_not_allowed=Não tem permissão para aceder a esta parte do repositó title=Pacotes desc=Gerir pacotes do repositório. empty=Ainda não há pacotes. -empty.documentation=Para obter mais informação sobre o registo de pacotes, veja a documentação. +empty.documentation=Para obter mais informação sobre o registo de pacotes, veja a documentação. empty.repo=Carregou um pacote mas este não é apresentado aqui? Vá às configurações do pacote e ligue-o a este repositório. registry.documentation=Para mais informação sobre o registo %s, veja a documentação. filter.type=Tipo From 09d50284422aa70af47c77e20b65b9f5c5e32c13 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 6 Dec 2023 09:13:59 +0800 Subject: [PATCH 012/480] Fix the runs will not be displayed bug when the main branch have no workflows but other branches have (#28359) --- routers/web/repo/actions/actions.go | 1 + templates/repo/actions/list.tmpl | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/routers/web/repo/actions/actions.go b/routers/web/repo/actions/actions.go index 3b10f0b9571..fd541647b71 100644 --- a/routers/web/repo/actions/actions.go +++ b/routers/web/repo/actions/actions.go @@ -200,6 +200,7 @@ func List(ctx *context.Context) { pager.AddParamString("actor", fmt.Sprint(actorID)) pager.AddParamString("status", fmt.Sprint(status)) ctx.Data["Page"] = pager + ctx.Data["HasWorkflowsOrRuns"] = len(workflows) > 0 || len(runs) > 0 ctx.HTML(http.StatusOK, tplListActions) } diff --git a/templates/repo/actions/list.tmpl b/templates/repo/actions/list.tmpl index ede4c82602d..62d30305b36 100644 --- a/templates/repo/actions/list.tmpl +++ b/templates/repo/actions/list.tmpl @@ -4,7 +4,7 @@
{{template "base/alert" .}} - {{if .workflows}} + {{if .HasWorkflowsOrRuns}}
{{if $.RenderedDescription}}
{{$.RenderedDescription|Str2html}}
{{end}}
@@ -23,6 +20,11 @@
- {{if $.EnableFeed}} - {{svg "octicon-rss" 18}} - {{end}}
{{if $.PullMirror}}
{{ctx.Locale.Tr "repo.mirror_from"}} {{$.PullMirror.RemoteAddress}}
@@ -55,6 +52,12 @@
{{end}} + {{if $.EnableFeed}} + {{/* An extra div-element is not necessary here, as this button does not secretly contain two buttons. */}} + + {{end}}
{{$.CsrfTokenHtml}}
diff --git a/templates/repo/release_tag_header.tmpl b/templates/repo/release_tag_header.tmpl index 4fe6a1251c4..f474fb89ead 100644 --- a/templates/repo/release_tag_header.tmpl +++ b/templates/repo/release_tag_header.tmpl @@ -10,10 +10,12 @@ {{ctx.Locale.PrettyNumber .NumTags}} {{ctx.Locale.TrN .NumTags "repo.tag" "repo.tags"}} {{end}} - {{if .EnableFeed}} - {{svg "octicon-rss" 18}} - {{end}}
+ {{if .EnableFeed}} + + {{svg "octicon-rss" 18}} {{ctx.Locale.Tr "rss_feed"}} + + {{end}} {{if and (not .PageIsTagList) .CanCreateRelease}} {{ctx.Locale.Tr "repo.release.new_release"}} diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl index 983491f97d7..4129a133b7e 100644 --- a/templates/repo/view_file.tmpl +++ b/templates/repo/view_file.tmpl @@ -43,7 +43,9 @@ {{svg "octicon-download"}} {{svg "octicon-copy" 14}} {{if .EnableFeed}} - {{svg "octicon-rss" 14}} + + {{svg "octicon-rss" 14}} + {{end}} {{if .Repository.CanEnableEditor}} {{if .CanEditFile}} From f4561c44b1cad700bf41537eb4db487fff34f6c9 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Thu, 7 Dec 2023 07:10:05 +0900 Subject: [PATCH 017/480] Fix incorrect run order of action jobs (#28367) When we pick up a job, all waiting jobs should firstly be ordered by update time, otherwise when there's a running job, if I rerun an older job, the older job will run first, as it's id is smaller. --- models/actions/task.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/actions/task.go b/models/actions/task.go index db0031b3b8d..96a6d2e80ca 100644 --- a/models/actions/task.go +++ b/models/actions/task.go @@ -234,7 +234,7 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask } var jobs []*ActionRunJob - if err := e.Where("task_id=? AND status=?", 0, StatusWaiting).And(jobCond).Asc("id").Find(&jobs); err != nil { + if err := e.Where("task_id=? AND status=?", 0, StatusWaiting).And(jobCond).Asc("updated", "id").Find(&jobs); err != nil { return nil, false, err } From ceedd90bf2d4a05fff85ce57971f8fc0504af60d Mon Sep 17 00:00:00 2001 From: GiteaBot Date: Thu, 7 Dec 2023 00:24:32 +0000 Subject: [PATCH 018/480] [skip ci] Updated translations via Crowdin --- options/locale/locale_de-DE.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options/locale/locale_de-DE.ini b/options/locale/locale_de-DE.ini index f970fdb6668..8a93e493f16 100644 --- a/options/locale/locale_de-DE.ini +++ b/options/locale/locale_de-DE.ini @@ -1760,7 +1760,7 @@ pulls.no_merge_desc=Dieser Pull-Request kann nicht gemerged werden, da keine Mer pulls.no_merge_helper=Aktiviere Mergeoptionen in den Repositoryeinstellungen oder merge den Pull-Request manuell. pulls.no_merge_wip=Dieser Pull Request kann nicht gemergt werden, da er als Work In Progress gekennzeichnet ist. pulls.no_merge_not_ready=Dieser Pull-Request kann nicht gemergt werden, überprüfe den Reviewstatus und die Statusprüfungen. -pulls.no_merge_access=Du bist nicht berechtigt, diesen Pull-Request zu Mergen. +pulls.no_merge_access=Du bist nicht berechtigt, diesen Pull-Request zu mergen. pulls.merge_pull_request=Merge Commit erstellen pulls.rebase_merge_pull_request=Rebasen und dann fast-forwarden pulls.rebase_merge_commit_pull_request=Rebasen und dann mergen From bfacb5c5017a41ec5bad48d4c639287634f7bfb0 Mon Sep 17 00:00:00 2001 From: Lauris BH Date: Thu, 7 Dec 2023 03:51:39 +0200 Subject: [PATCH 019/480] Fix margin in server signed signature verification view (#28379) Before: ![image](https://github.com/go-gitea/gitea/assets/165205/e2e2256d-03c5-4ab8-8ed9-08ef68571a43) After: ![image](https://github.com/go-gitea/gitea/assets/165205/804132ef-18f9-4ab8-949d-f6c71e7f4d24) --- templates/repo/commit_page.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl index efdbb23e00a..2a4240045cb 100644 --- a/templates/repo/commit_page.tmpl +++ b/templates/repo/commit_page.tmpl @@ -201,7 +201,7 @@ {{else}} {{svg "gitea-lock-cog" 16 "gt-mr-3"}} {{ctx.Locale.Tr "repo.commits.signed_by"}}: - {{ctx.AvatarUtils.AvatarByEmail .Verification.SigningEmail "" 28}} + {{ctx.AvatarUtils.AvatarByEmail .Verification.SigningEmail "" 28 "gt-mr-3"}} {{.Verification.SigningUser.GetDisplayName}} {{end}} {{else}} From dac7728e9d05b25f1132deefce92a61afd36973f Mon Sep 17 00:00:00 2001 From: "Panagiotis \"Ivory\" Vasilopoulos" Date: Thu, 7 Dec 2023 03:01:32 +0000 Subject: [PATCH 020/480] Issue fixes for RSS feed improvements (#28380) Follow-up for #28368 - Just replace button with an a-element with the button class - Remove useless link-action class from template/org/home.tmpl --- templates/org/home.tmpl | 4 ++-- templates/repo/header.tmpl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl index a84e3efc89d..fc65d4691cb 100644 --- a/templates/org/home.tmpl +++ b/templates/org/home.tmpl @@ -21,9 +21,9 @@
{{end}} -
+