From 2814f2fea1313992c588444ead3643e54ea57c4d Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 20 Sep 2023 08:51:36 +0800 Subject: [PATCH 1/6] Fix incorrect test code for error handling (#27139) If `assert.NoError` fails, it should return. Otherwise the code could still execute even if the error occurs. --- services/wiki/wiki_test.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/services/wiki/wiki_test.go b/services/wiki/wiki_test.go index 6f05dedab6..81a688b046 100644 --- a/services/wiki/wiki_test.go +++ b/services/wiki/wiki_test.go @@ -168,7 +168,9 @@ func TestRepository_AddWikiPage(t *testing.T) { assert.NoError(t, AddWikiPage(git.DefaultContext, doer, repo, webPath, wikiContent, commitMsg)) // Now need to show that the page has been added: gitRepo, err := git.OpenRepository(git.DefaultContext, repo.WikiPath()) - assert.NoError(t, err) + if !assert.NoError(t, err) { + return + } defer gitRepo.Close() masterTree, err := gitRepo.GetTree(DefaultBranch) assert.NoError(t, err) @@ -238,7 +240,9 @@ func TestRepository_DeleteWikiPage(t *testing.T) { // Now need to show that the page has been added: gitRepo, err := git.OpenRepository(git.DefaultContext, repo.WikiPath()) - assert.NoError(t, err) + if !assert.NoError(t, err) { + return + } defer gitRepo.Close() masterTree, err := gitRepo.GetTree(DefaultBranch) assert.NoError(t, err) @@ -251,7 +255,9 @@ func TestPrepareWikiFileName(t *testing.T) { unittest.PrepareTestEnv(t) repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) gitRepo, err := git.OpenRepository(git.DefaultContext, repo.WikiPath()) - assert.NoError(t, err) + if !assert.NoError(t, err) { + return + } defer gitRepo.Close() tests := []struct { @@ -303,7 +309,9 @@ func TestPrepareWikiFileName_FirstPage(t *testing.T) { assert.NoError(t, err) gitRepo, err := git.OpenRepository(git.DefaultContext, tmpDir) - assert.NoError(t, err) + if !assert.NoError(t, err) { + return + } defer gitRepo.Close() existence, newWikiPath, err := prepareGitPath(gitRepo, "Home") From 74a5db03fde795ffe1a97dc6ffa958a4e11141ec Mon Sep 17 00:00:00 2001 From: hazy Date: Tue, 19 Sep 2023 20:48:44 -0500 Subject: [PATCH 2/6] Fix: treat tab "overview" as "repositories" in user profiles without readme (#27124) Beginning since 2af30f715e64dbb0a3900168e3768ffb36c06392, Gitea has a 500 error when visiting a user profile with `?tab=overview` in the URL when the user doesn't have a `.profile/README.md`, because the backend code assumes that if the tab is overview a profile repository must exist, and checks that the repository is nil aren't done. In this PR I treat `?tab=overview` the same as if no tab is set in the URL, which corrects this behaviour- Now, when visiting `?tab=overview`, if `.profile/README.md` exists on that user's profile it'll show that as it should, otherwise it'll show the repositories tab. Co-authored-by: wxiaoguang --- routers/web/user/profile.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go index 380a681b9d..d9a0124020 100644 --- a/routers/web/user/profile.go +++ b/routers/web/user/profile.go @@ -77,8 +77,9 @@ func userProfile(ctx *context.Context) { func prepareUserProfileTabData(ctx *context.Context, showPrivate bool, profileGitRepo *git.Repository, profileReadme *git.Blob) { // if there is a profile readme, default to "overview" page, otherwise, default to "repositories" page + // if there is not a profile readme, the overview tab should be treated as the repositories tab tab := ctx.FormString("tab") - if tab == "" { + if tab == "" || tab == "overview" { if profileReadme != nil { tab = "overview" } else { From 24a215e317103471aeb864f365089a36076efc1d Mon Sep 17 00:00:00 2001 From: delvh Date: Wed, 20 Sep 2023 05:02:58 +0200 Subject: [PATCH 3/6] Remove outdated paragraphs when comparing Gitea Actions to GitHub Actions (#27119) No backport needed as this new state only applies to 1.21+ --------- Co-authored-by: Lunny Xiao --- .../content/usage/actions/comparison.en-us.md | 22 ++++++++----------- .../content/usage/actions/comparison.zh-cn.md | 12 +++++----- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/docs/content/usage/actions/comparison.en-us.md b/docs/content/usage/actions/comparison.en-us.md index 64a5eff4d5..caec9d3dea 100644 --- a/docs/content/usage/actions/comparison.en-us.md +++ b/docs/content/usage/actions/comparison.en-us.md @@ -91,12 +91,6 @@ As a workaround, you can use [go-hashfiles](https://gitea.com/actions/go-hashfil ## Missing features -### Variables - -See [Variables](https://docs.github.com/en/actions/learn-github-actions/variables). - -It's under development. - ### Problem Matchers Problem Matchers are a way to scan the output of actions for a specified regex pattern and surface that information prominently in the UI. @@ -120,15 +114,17 @@ Pre and Post steps don't have their own section in the job log user interface. ### Downloading actions -Gitea Actions doesn't download actions from GitHub by default. -"By default" means that you don't specify the host in the `uses` field, like `uses: actions/checkout@v3`. -As a contrast, `uses: https://github.com/actions/checkout@v3` has specified host. +Previously (Pre 1.21.0), `[actions].DEFAULT_ACTIONS_URL` defaulted to `https://gitea.com`. +We have since restricted this option to only allow two values (`github` and `self`). +When set to `github`, the new default, Gitea will download non-fully-qualified actions from . +For example, if you use `uses: actions/checkout@v3`, it will download the checkout repository from . -The missing host will be filled with `https://gitea.com` if you don't configure it. -That means `uses: actions/checkout@v3` will download the action from [gitea.com/actions/checkout](https://gitea.com/actions/checkout), instead of [github.com/actions/checkout](https://github.com/actions/checkout). +If you want to download an action from another git hoster, you can use an absolute URL, e.g. `uses: https://gitea.com/actions/checkout@v3`. -As mentioned, it's configurable. -If you want your runners to download actions from GitHub or your own Gitea instance by default, you can configure it by setting `[actions].DEFAULT_ACTIONS_URL`. See [Configuration Cheat Sheet](administration/config-cheat-sheet.md#actions-actions). +If your Gitea instance is in an intranet or a restricted area, you can set the URL to `self` to only download actions from your own instance by default. +Of course, you can still use absolute URLs in workflows. + +More details about the `[actions].DEFAULT_ACTIONS_URL` configuration can be found in the [Configuration Cheat Sheet](administration/config-cheat-sheet.md#actions-actions)。 ### Context availability diff --git a/docs/content/usage/actions/comparison.zh-cn.md b/docs/content/usage/actions/comparison.zh-cn.md index cfea7970f7..5dae75a44b 100644 --- a/docs/content/usage/actions/comparison.zh-cn.md +++ b/docs/content/usage/actions/comparison.zh-cn.md @@ -120,15 +120,13 @@ Gitea Actions目前不支持此功能。 ### 下载Actions -Gitea Actions默认不从GitHub下载Actions。 -"默认" 意味着您在`uses` 字段中不指定主机,如`uses: actions/checkout@v3`。 -相反,`uses: https://github.com/actions/checkout@v3`是有指定主机的。 +当 `[actions].DEFAULT_ACTIONS_URL` 保持默认值为 `github` 时,Gitea将会从 https://github.com 下载相对路径的actions。比如: +如果你使用 `uses: actions/checkout@v3`,Gitea将会从 https://github.com/actions/checkout.git 下载这个 actions 项目。 +如果你想要从另外一个 Git服务下载actions,你只需要使用绝对URL `uses: https://gitea.com/actions/checkout@v3` 来下载。 -如果您不进行配置,缺失的主机将填充为`https://gitea.com`。 -这意味着`uses: actions/checkout@v3`将从[gitea.com/actions/checkout](https://gitea.com/actions/checkout)下载该Action,而不是[github.com/actions/checkout](https://github.com/actions/checkout)。 +如果你的 Gitea 实例是部署在一个互联网限制的网络中,有可以使用绝对地址来下载 actions。你也可以讲配置项修改为 `[actions].DEFAULT_ACTIONS_URL = self`。这样所有的相对路径的actions引用,将不再会从 github.com 去下载,而会从这个 Gitea 实例自己的仓库中去下载。例如: `uses: actions/checkout@v3` 将会从 `[server].ROOT_URL`/actions/checkout.git 这个地址去下载 actions。 -正如前面提到的,这是可配置的。 -如果您希望您的运行程序默认从GitHub或您自己的Gitea实例下载动作,您可以通过设置`[actions].DEFAULT_ACTIONS_URL`进行配置。请参阅[配置备忘单](administration/config-cheat-sheet.md#actions-actions)。 +设置`[actions].DEFAULT_ACTIONS_URL`进行配置。请参阅[配置备忘单](administration/config-cheat-sheet.md#actions-actions)。 ### 上下文可用性 From 9336286e353370d76d9804043ee6af8f2fe35e00 Mon Sep 17 00:00:00 2001 From: Zettat123 Date: Wed, 20 Sep 2023 14:28:35 +0800 Subject: [PATCH 4/6] Improve actions docs related to `pull_request` event (#27126) Related to #27039 The `ref` property in Gitea Actions is different from GitHub Actions. This PR improves the documentation to explain the difference. --- docs/content/usage/actions/faq.en-us.md | 3 +++ docs/content/usage/actions/faq.zh-cn.md | 3 +++ 2 files changed, 6 insertions(+) diff --git a/docs/content/usage/actions/faq.en-us.md b/docs/content/usage/actions/faq.en-us.md index 031509a033..1d59872936 100644 --- a/docs/content/usage/actions/faq.en-us.md +++ b/docs/content/usage/actions/faq.en-us.md @@ -180,3 +180,6 @@ For events supported only by GitHub, see GitHub's [documentation](https://docs.g | pull_request_review_comment | `created`, `edited` | | release | `published`, `edited` | | registry_package | `published` | + +> For `pull_request` events, in [GitHub Actions](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request), the `ref` is `refs/pull/:prNumber/merge`, which is a reference to the merge commit preview. However, Gitea has no such reference. +> Therefore, the `ref` in Gitea Actions is `refs/pull/:prNumber/head`, which points to the head of pull request rather than the preview of the merge commit. diff --git a/docs/content/usage/actions/faq.zh-cn.md b/docs/content/usage/actions/faq.zh-cn.md index f5dc8e179b..7bb79d02fc 100644 --- a/docs/content/usage/actions/faq.zh-cn.md +++ b/docs/content/usage/actions/faq.zh-cn.md @@ -180,3 +180,6 @@ defaults: | pull_request_review_comment | `created`, `edited` | | release | `published`, `edited` | | registry_package | `published` | + +> 对于 `pull_request` 事件,在 [GitHub Actions](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request) 中 `ref` 是 `refs/pull/:prNumber/merge`,它指向这个拉取请求合并提交的一个预览。但是 Gitea 没有这种 reference。 +> 因此,Gitea Actions 中 `ref` 是 `refs/pull/:prNumber/head`,它指向这个拉取请求的头分支而不是合并提交的预览。 From 707c69f399d311aaa11ca62a27293244e85cb043 Mon Sep 17 00:00:00 2001 From: delvh Date: Wed, 20 Sep 2023 22:28:17 +0200 Subject: [PATCH 5/6] Fix successful return value for `SyncAndGetUserSpecificDiff` (#27152) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A function should not return an error when it is successful. Otherwise, things like https://discord.com/channels/322538954119184384/322538954119184384/1153705341620600833 happen… --- services/gitdiff/gitdiff.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/gitdiff/gitdiff.go b/services/gitdiff/gitdiff.go index 4cc093e65d..fd0f32717c 100644 --- a/services/gitdiff/gitdiff.go +++ b/services/gitdiff/gitdiff.go @@ -1343,7 +1343,7 @@ outer: } } - return diff, err + return diff, nil } // CommentAsDiff returns c.Patch as *Diff From d7f73a1334ab7a97d4e055b7c58cdd9ac303f77a Mon Sep 17 00:00:00 2001 From: delvh Date: Wed, 20 Sep 2023 23:18:53 +0200 Subject: [PATCH 6/6] Start development on Gitea 1.22 (#27155)