From 3618715fab1e5e3a26d1184398bf4134eb45e6e6 Mon Sep 17 00:00:00 2001 From: JakobDev Date: Thu, 30 Nov 2023 16:26:56 +0100 Subject: [PATCH 01/19] Add missing variable in tag list (#28305) This fixes a regression from #25859 If a tag has no Release, Gitea will show a Link to create a Release for the Tag if the User has the Permission to do this, but the variable to indicate that is no longer set. Used here: https://github.com/go-gitea/gitea/blob/1bfcdeef4cca0f5509476358e5931c13d37ed1ca/templates/repo/tag/list.tmpl#L39-L41 --- routers/web/repo/release.go | 1 + 1 file changed, 1 insertion(+) diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go index 761dadd5444c..595d599fe131 100644 --- a/routers/web/repo/release.go +++ b/routers/web/repo/release.go @@ -174,6 +174,7 @@ func TagsList(ctx *context.Context) { // Disable the showCreateNewBranch form in the dropdown on this page. ctx.Data["CanCreateBranch"] = false ctx.Data["HideBranchesInDropdown"] = true + ctx.Data["CanCreateRelease"] = ctx.Repo.CanWrite(unit.TypeReleases) && !ctx.Repo.Repository.IsArchived listOptions := db.ListOptions{ Page: ctx.FormInt("page"), From 14354e4f8edb35b6ff46ea066098fc1d9fe93d5a Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Fri, 1 Dec 2023 02:26:52 +0100 Subject: [PATCH 02/19] Read `previous` info from git blame (#28306) Fixes #28280 Reads the `previous` info from the `git blame` output instead of calculating it afterwards. --- modules/git/blame.go | 37 +++++++++++++++++++++++++------------ modules/git/blame_test.go | 28 ++++++++++++++++------------ routers/web/repo/blame.go | 38 ++++++++------------------------------ 3 files changed, 49 insertions(+), 54 deletions(-) diff --git a/modules/git/blame.go b/modules/git/blame.go index 6728a6bed85f..93c7f184fa22 100644 --- a/modules/git/blame.go +++ b/modules/git/blame.go @@ -11,6 +11,7 @@ import ( "io" "os" "regexp" + "strings" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/util" @@ -18,8 +19,10 @@ import ( // BlamePart represents block of blame - continuous lines with one sha type BlamePart struct { - Sha string - Lines []string + Sha string + Lines []string + PreviousSha string + PreviousPath string } // BlameReader returns part of file blame one by one @@ -43,30 +46,38 @@ func (r *BlameReader) NextPart() (*BlamePart, error) { var blamePart *BlamePart if r.lastSha != nil { - blamePart = &BlamePart{*r.lastSha, make([]string, 0)} + blamePart = &BlamePart{ + Sha: *r.lastSha, + Lines: make([]string, 0), + } } - var line []byte + var lineBytes []byte var isPrefix bool var err error for err != io.EOF { - line, isPrefix, err = r.bufferedReader.ReadLine() + lineBytes, isPrefix, err = r.bufferedReader.ReadLine() if err != nil && err != io.EOF { return blamePart, err } - if len(line) == 0 { + if len(lineBytes) == 0 { // isPrefix will be false continue } - lines := shaLineRegex.FindSubmatch(line) + line := string(lineBytes) + + lines := shaLineRegex.FindStringSubmatch(line) if lines != nil { - sha1 := string(lines[1]) + sha1 := lines[1] if blamePart == nil { - blamePart = &BlamePart{sha1, make([]string, 0)} + blamePart = &BlamePart{ + Sha: sha1, + Lines: make([]string, 0), + } } if blamePart.Sha != sha1 { @@ -81,9 +92,11 @@ func (r *BlameReader) NextPart() (*BlamePart, error) { return blamePart, nil } } else if line[0] == '\t' { - code := line[1:] - - blamePart.Lines = append(blamePart.Lines, string(code)) + blamePart.Lines = append(blamePart.Lines, line[1:]) + } else if strings.HasPrefix(line, "previous ") { + parts := strings.SplitN(line[len("previous "):], " ", 2) + blamePart.PreviousSha = parts[0] + blamePart.PreviousPath = parts[1] } // need to munch to end of line... diff --git a/modules/git/blame_test.go b/modules/git/blame_test.go index 013350ac2f4e..040f4e822dac 100644 --- a/modules/git/blame_test.go +++ b/modules/git/blame_test.go @@ -24,15 +24,17 @@ func TestReadingBlameOutput(t *testing.T) { parts := []*BlamePart{ { - "72866af952e98d02a73003501836074b286a78f6", - []string{ + Sha: "72866af952e98d02a73003501836074b286a78f6", + Lines: []string{ "# test_repo", "Test repository for testing migration from github to gitea", }, }, { - "f32b0a9dfd09a60f616f29158f772cedd89942d2", - []string{"", "Do not make any changes to this repo it is used for unit testing"}, + Sha: "f32b0a9dfd09a60f616f29158f772cedd89942d2", + Lines: []string{"", "Do not make any changes to this repo it is used for unit testing"}, + PreviousSha: "72866af952e98d02a73003501836074b286a78f6", + PreviousPath: "README.md", }, } @@ -64,16 +66,18 @@ func TestReadingBlameOutput(t *testing.T) { full := []*BlamePart{ { - "af7486bd54cfc39eea97207ca666aa69c9d6df93", - []string{"line", "line"}, + Sha: "af7486bd54cfc39eea97207ca666aa69c9d6df93", + Lines: []string{"line", "line"}, }, { - "45fb6cbc12f970b04eacd5cd4165edd11c8d7376", - []string{"changed line"}, + Sha: "45fb6cbc12f970b04eacd5cd4165edd11c8d7376", + Lines: []string{"changed line"}, + PreviousSha: "af7486bd54cfc39eea97207ca666aa69c9d6df93", + PreviousPath: "blame.txt", }, { - "af7486bd54cfc39eea97207ca666aa69c9d6df93", - []string{"line", "line", ""}, + Sha: "af7486bd54cfc39eea97207ca666aa69c9d6df93", + Lines: []string{"line", "line", ""}, }, } @@ -89,8 +93,8 @@ func TestReadingBlameOutput(t *testing.T) { Bypass: false, Parts: []*BlamePart{ { - "af7486bd54cfc39eea97207ca666aa69c9d6df93", - []string{"line", "line", "changed line", "line", "line", ""}, + Sha: "af7486bd54cfc39eea97207ca666aa69c9d6df93", + Lines: []string{"line", "line", "changed line", "line", "line", ""}, }, }, }, diff --git a/routers/web/repo/blame.go b/routers/web/repo/blame.go index 1f1cca897ef5..52d350ff665a 100644 --- a/routers/web/repo/blame.go +++ b/routers/web/repo/blame.go @@ -114,12 +114,12 @@ func RefBlame(ctx *context.Context) { return } - commitNames, previousCommits := processBlameParts(ctx, result.Parts) + commitNames := processBlameParts(ctx, result.Parts) if ctx.Written() { return } - renderBlame(ctx, result.Parts, commitNames, previousCommits) + renderBlame(ctx, result.Parts, commitNames) ctx.HTML(http.StatusOK, tplRepoHome) } @@ -185,12 +185,9 @@ func fillBlameResult(br *git.BlameReader, r *blameResult) error { return nil } -func processBlameParts(ctx *context.Context, blameParts []git.BlamePart) (map[string]*user_model.UserCommit, map[string]string) { +func processBlameParts(ctx *context.Context, blameParts []git.BlamePart) map[string]*user_model.UserCommit { // store commit data by SHA to look up avatar info etc commitNames := make(map[string]*user_model.UserCommit) - // previousCommits contains links from SHA to parent SHA, - // if parent also contains the current TreePath. - previousCommits := make(map[string]string) // and as blameParts can reference the same commits multiple // times, we cache the lookup work locally commits := make([]*git.Commit, 0, len(blameParts)) @@ -214,29 +211,11 @@ func processBlameParts(ctx *context.Context, blameParts []git.BlamePart) (map[st } else { ctx.ServerError("Repo.GitRepo.GetCommit", err) } - return nil, nil + return nil } commitCache[sha] = commit } - // find parent commit - if commit.ParentCount() > 0 { - psha := commit.Parents[0] - previousCommit, ok := commitCache[psha.String()] - if !ok { - previousCommit, _ = commit.Parent(0) - if previousCommit != nil { - commitCache[psha.String()] = previousCommit - } - } - // only store parent commit ONCE, if it has the file - if previousCommit != nil { - if haz1, _ := previousCommit.HasFile(ctx.Repo.TreePath); haz1 { - previousCommits[commit.ID.String()] = previousCommit.ID.String() - } - } - } - commits = append(commits, commit) } @@ -245,10 +224,10 @@ func processBlameParts(ctx *context.Context, blameParts []git.BlamePart) (map[st commitNames[c.ID.String()] = c } - return commitNames, previousCommits + return commitNames } -func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames map[string]*user_model.UserCommit, previousCommits map[string]string) { +func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames map[string]*user_model.UserCommit) { repoLink := ctx.Repo.RepoLink language := "" @@ -295,7 +274,6 @@ func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames m } commit := commitNames[part.Sha] - previousSha := previousCommits[part.Sha] if index == 0 { // Count commit number commitCnt++ @@ -313,8 +291,8 @@ func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames m br.Avatar = gotemplate.HTML(avatar) br.RepoLink = repoLink br.PartSha = part.Sha - br.PreviousSha = previousSha - br.PreviousShaURL = fmt.Sprintf("%s/blame/commit/%s/%s", repoLink, url.PathEscape(previousSha), util.PathEscapeSegments(ctx.Repo.TreePath)) + br.PreviousSha = part.PreviousSha + br.PreviousShaURL = fmt.Sprintf("%s/blame/commit/%s/%s", repoLink, url.PathEscape(part.PreviousSha), util.PathEscapeSegments(part.PreviousPath)) br.CommitURL = fmt.Sprintf("%s/commit/%s", repoLink, url.PathEscape(part.Sha)) br.CommitMessage = commit.CommitMessage br.CommitSince = commitSince From 1ae33e0badc21c8b2e3596508347d017a46150e0 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Fri, 1 Dec 2023 20:42:42 +0900 Subject: [PATCH 03/19] Fix links in docs (#28302) Close #28287 ## How to test it in local convert Makefile L34 into: ``` cd .tmp/upstream-docs && git clean -f && git reset --hard && git fetch origin pull/28302/head:pr28302 && git switch pr28302 ``` --- docs/content/administration/https-support.zh-cn.md | 2 +- docs/content/development/api-usage.en-us.md | 5 +---- docs/content/development/api-usage.zh-cn.md | 3 +-- docs/content/installation/from-binary.zh-cn.md | 4 ++-- docs/content/installation/from-source.zh-cn.md | 2 +- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/docs/content/administration/https-support.zh-cn.md b/docs/content/administration/https-support.zh-cn.md index add7906cc62c..8beb06e80f89 100644 --- a/docs/content/administration/https-support.zh-cn.md +++ b/docs/content/administration/https-support.zh-cn.md @@ -33,7 +33,7 @@ CERT_FILE = cert.pem KEY_FILE = key.pem ``` -请注意,如果您的证书由第三方证书颁发机构签名(即不是自签名的),则 cert.pem 应包含证书链。服务器证书必须是 cert.pem 中的第一个条目,后跟中介(如果有)。不必包含根证书,因为连接客户端必须已经拥有根证书才能建立信任关系。要了解有关配置值的更多信息,请查看 [配置备忘单](../config-cheat-sheet#server-server)。 +请注意,如果您的证书由第三方证书颁发机构签名(即不是自签名的),则 cert.pem 应包含证书链。服务器证书必须是 cert.pem 中的第一个条目,后跟中介(如果有)。不必包含根证书,因为连接客户端必须已经拥有根证书才能建立信任关系。要了解有关配置值的更多信息,请查看 [配置备忘单](administration/config-cheat-sheet#server-server)。 对于“CERT_FILE”或“KEY_FILE”字段,当文件路径是相对路径时,文件路径相对于“GITEA_CUSTOM”环境变量。它也可以是绝对路径。 diff --git a/docs/content/development/api-usage.en-us.md b/docs/content/development/api-usage.en-us.md index 465f4d380c8e..94dac70b88e4 100644 --- a/docs/content/development/api-usage.en-us.md +++ b/docs/content/development/api-usage.en-us.md @@ -19,10 +19,7 @@ menu: ## Enabling/configuring API access -By default, `ENABLE_SWAGGER` is true, and -`MAX_RESPONSE_ITEMS` is set to 50. See [Config Cheat -Sheet](administration/config-cheat-sheet.md) for more -information. +By default, `ENABLE_SWAGGER` is true, and `MAX_RESPONSE_ITEMS` is set to 50. See [Config Cheat Sheet](administration/config-cheat-sheet.md) for more information. ## Authentication diff --git a/docs/content/development/api-usage.zh-cn.md b/docs/content/development/api-usage.zh-cn.md index c7eeceeb7d79..96c19972940c 100644 --- a/docs/content/development/api-usage.zh-cn.md +++ b/docs/content/development/api-usage.zh-cn.md @@ -19,8 +19,7 @@ menu: ## 开启/配置 API 访问 -通常情况下, `ENABLE_SWAGGER` 默认开启并且参数 `MAX_RESPONSE_ITEMS` 默认为 50。您可以从 [Config Cheat -Sheet](administration/config-cheat-sheet.md) 中获取更多配置相关信息。 +通常情况下, `ENABLE_SWAGGER` 默认开启并且参数 `MAX_RESPONSE_ITEMS` 默认为 50。您可以从 [Config Cheat Sheet](administration/config-cheat-sheet.md) 中获取更多配置相关信息。 ## 通过 API 认证 diff --git a/docs/content/installation/from-binary.zh-cn.md b/docs/content/installation/from-binary.zh-cn.md index 56c7cc0ae0bd..216a6be51e38 100644 --- a/docs/content/installation/from-binary.zh-cn.md +++ b/docs/content/installation/from-binary.zh-cn.md @@ -117,7 +117,7 @@ chmod 770 /etc/gitea - 使用 `gitea generate secret` 创建 `SECRET_KEY` 和 `INTERNAL_TOKEN` - 提供所有必要的密钥 -详情参考 [命令行文档](/zh-cn/command-line/) 中有关 `gitea generate secret` 的内容。 +详情参考 [命令行文档](administration/command-line.md) 中有关 `gitea generate secret` 的内容。 ### 配置 Gitea 工作路径 @@ -209,6 +209,6 @@ remote: ./hooks/pre-receive.d/gitea: line 2: [...]: No such file or directory 如果您没有使用 Gitea 内置的 SSH 服务器,您还需要通过在管理选项中运行任务 `Update the '.ssh/authorized_keys' file with Gitea SSH keys.` 来重新编写授权密钥文件。 -> 更多经验总结,请参考英文版 [Troubleshooting](/en-us/install-from-binary/#troubleshooting) +> 更多经验总结,请参考英文版 [Troubleshooting](https://docs.gitea.com/installation/install-from-binary#troubleshooting) 如果从本页中没有找到你需要的内容,请访问 [帮助页面](help/support.md) diff --git a/docs/content/installation/from-source.zh-cn.md b/docs/content/installation/from-source.zh-cn.md index 40a314340c61..4f3464588a90 100644 --- a/docs/content/installation/from-source.zh-cn.md +++ b/docs/content/installation/from-source.zh-cn.md @@ -64,7 +64,7 @@ git checkout v@version@ # or git checkout pr-xyz - `go` @minGoVersion@ 或更高版本,请参阅 [这里](https://golang.org/dl/) - `node` @minNodeVersion@ 或更高版本,并且安装 `npm`, 请参阅 [这里](https://nodejs.org/zh-cn/download/) -- `make`, 请参阅 [这里](/zh-cn/hacking-on-gitea/) +- `make`, 请参阅 [这里](development/hacking-on-gitea.md) 为了尽可能简化编译过程,提供了各种 [make任务](https://github.com/go-gitea/gitea/blob/main/Makefile)。 From 004ab3758c19244c2d961fce71fb32e5bb9949db Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Fri, 1 Dec 2023 20:45:04 +0900 Subject: [PATCH 04/19] Fix wrong link in `protect_branch_name_pattern_desc` (#28313) The current href will link to `https://domain/owner/repo/settings/branches/github.com/gobwas/glob` --- options/locale/locale_en-US.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index fa7eee9bc558..9c582a885013 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2312,7 +2312,7 @@ settings.dismiss_stale_approvals_desc = When new commits that change the content settings.require_signed_commits = Require Signed Commits settings.require_signed_commits_desc = Reject pushes to this branch if they are unsigned or unverifiable. settings.protect_branch_name_pattern = Protected Branch Name Pattern -settings.protect_branch_name_pattern_desc = "Protected branch name patterns. See the documentation for pattern syntax. Examples: main, release/**" +settings.protect_branch_name_pattern_desc = "Protected branch name patterns. See the documentation for pattern syntax. Examples: main, release/**" settings.protect_patterns = Patterns settings.protect_protected_file_patterns = "Protected file patterns (separated using semicolon ';'):" settings.protect_protected_file_patterns_desc = "Protected files are not allowed to be changed directly even if user has rights to add, edit, or delete files in this branch. Multiple patterns can be separated using semicolon (';'). See github.com/gobwas/glob documentation for pattern syntax. Examples: .drone.yml, /docs/**/*.txt." From 6ad145f5bd5fc2d32a5b829a708e0f9038191c63 Mon Sep 17 00:00:00 2001 From: JakobDev Date: Fri, 1 Dec 2023 21:31:40 +0100 Subject: [PATCH 05/19] Keep profile tab when clicking on Language (#28320) Fixes https://codeberg.org/Codeberg/Community/issues/1355 --- templates/explore/repo_list.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/explore/repo_list.tmpl b/templates/explore/repo_list.tmpl index 1976ed5a1597..05406ad55944 100644 --- a/templates/explore/repo_list.tmpl +++ b/templates/explore/repo_list.tmpl @@ -28,7 +28,7 @@
{{if .PrimaryLanguage}} - + {{.PrimaryLanguage.Language}} {{end}} From bffbf08f26656c2c073da2a989f3abc38fdbb444 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 3 Dec 2023 12:22:44 +0100 Subject: [PATCH 06/19] 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 e0b87faedbf8..f1e21a2d40ed 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 07/19] [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 000000000000..b329db3bb50f --- /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 000000000000..4e77909ed75e --- /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 08/19] 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 3b289fb68f2e..580fb08a9ee2 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 94dea4ac4117..5b0d982e96f5 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 d2345c3b88e3..2b901411e292 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 f306435409e3..2a3ebc4e772d 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 1d200e23b7a7..56c65e240143 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 4be1f52dd5c6..c81cc5c10a64 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 e0d2e102e5ef..7fd1f4e0f8d0 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 3a080a3505a8..728715bbc75f 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 e98eff9cffb4..d8f8d462d359 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 7eb4c8ea446a..ec40d3afeaff 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 bd560fa325fe..481d7482b498 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 09/19] 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 cbde53f9611d..fca3cf420320 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 1d0dc83cae85..c9db0247f6d9 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 10/19] 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 b09be25ba099..4ff8f6148f74 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 11/19] 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 6c70bffca33b..b1d3b5f45717 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 d32684c1af3b..2541726a64b8 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 12/19] 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 2ba35e21380b..722ee3f87b19 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 f5d8b67e16d9..2e161940b8ca 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 fc4c4d1c4b66..6d3b0688f2a3 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 13/19] 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 ddc2cbd4ec83..6ad0a2326bd1 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 14/19] 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 5dccd8bfa0d9..2c7cbadf0d89 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 15/19] 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 84c3a1587afa..8621a371bd56 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 16/19] [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 9d9c5eada1c0..b3c60333698a 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 17/19] 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 3b10f0b9571e..fd541647b716 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 ede4c82602da..62d30305b360 100644 --- a/templates/repo/actions/list.tmpl +++ b/templates/repo/actions/list.tmpl @@ -4,7 +4,7 @@
{{template "base/alert" .}} - {{if .workflows}} + {{if .HasWorkflowsOrRuns}}