From 723fa1c96610fbedefb6cdf11348dbef17fd2014 Mon Sep 17 00:00:00 2001 From: forgejo-backport-action Date: Sun, 4 May 2025 22:26:52 +0000 Subject: [PATCH 01/10] [v11.0/forgejo] fix: remove artificial delay for PR update (#7774) **Backport:** https://codeberg.org/forgejo/forgejo/pulls/7773 - I was not able to find a reasoning in the pull request (https://github.com/go-gitea/gitea/pull/9784) for the existence of this `time.Sleep`. The best I could come up with during manual testing is that there's a brief moment where 'this pull request is missing fork information' is shown, this was caused by an incorrect condition. - Added integration test. Co-authored-by: Gusted Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7774 Reviewed-by: Gusted Co-authored-by: forgejo-backport-action Co-committed-by: forgejo-backport-action --- models/fixtures/pull_request.yml | 1 + routers/web/repo/pull.go | 5 +---- tests/integration/pull_update_test.go | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/models/fixtures/pull_request.yml b/models/fixtures/pull_request.yml index fbc0d504f8..79051ffb6c 100644 --- a/models/fixtures/pull_request.yml +++ b/models/fixtures/pull_request.yml @@ -65,6 +65,7 @@ merge_base: 985f0301dba5e7b34be866819cd15ad3d8f508ee has_merged: false allow_maintainer_edit: true + commits_behind: 1 - id: 6 diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index a54a31ac36..6ba1bca181 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -14,7 +14,6 @@ import ( "net/url" "strconv" "strings" - "time" "forgejo.org/models" activities_model "forgejo.org/models/activities" @@ -727,7 +726,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C ctx.Data["HeadBranchCommitID"] = headBranchSha ctx.Data["PullHeadCommitID"] = sha - if pull.HeadRepo == nil || !headBranchExist || (!pull.Issue.IsClosed && (headBranchSha != sha)) { + if pull.HeadRepo == nil || !headBranchExist || (!pull.Issue.IsClosed && !pull.IsChecking() && (headBranchSha != sha)) { ctx.Data["IsPullRequestBroken"] = true if pull.IsSameRepo() { ctx.Data["HeadTarget"] = pull.HeadBranch @@ -1207,8 +1206,6 @@ func UpdatePullRequest(ctx *context.Context) { return } - time.Sleep(1 * time.Second) - ctx.Flash.Success(ctx.Tr("repo.pulls.update_branch_success")) ctx.Redirect(issue.Link()) } diff --git a/tests/integration/pull_update_test.go b/tests/integration/pull_update_test.go index 18766e8fa4..e1fec8c77e 100644 --- a/tests/integration/pull_update_test.go +++ b/tests/integration/pull_update_test.go @@ -273,3 +273,19 @@ func createOutdatedPR(t *testing.T, actor, forkOrg *user_model.User) *issues_mod return issue.PullRequest } + +func TestStatusDuringUpdate(t *testing.T) { + onGiteaRun(t, func(t *testing.T, u *url.URL) { + session := loginUser(t, "user2") + + // Adjust this pull request to be in the conflict checker and having a head + // branch that is pointing to the an incorrect commit ID. + _, err := db.GetEngine(t.Context()).Cols("status", "head_branch").Update(&issues_model.PullRequest{ID: 5, Status: issues_model.PullRequestStatusChecking, HeadBranch: "master"}) + require.NoError(t, err) + + resp := session.MakeRequest(t, NewRequest(t, "GET", "/user2/repo1/pulls/5"), http.StatusOK) + htmlDoc := NewHTMLParser(t, resp.Body) + + assert.Contains(t, htmlDoc.Find(".merge-section .item").Text(), "Merge conflict checking is in progress. Try again in few moments.") + }) +} From 4a30f59e6e54129a0951a836aabee0131b6c8ac1 Mon Sep 17 00:00:00 2001 From: forgejo-backport-action Date: Mon, 5 May 2025 06:01:59 +0000 Subject: [PATCH 02/10] [v11.0/forgejo] fix: make hash pattern more strict (#7779) **Backport:** https://codeberg.org/forgejo/forgejo/pulls/7775 - Ensure that the last path is `commit/`, `tree/` or `blob/`. - Resolves forgejo/forgejo#7767 - Follow up forgejo/forgejo#6784 - Added unit test ## Release notes - Bug fixes - [PR](https://codeberg.org/forgejo/forgejo/pulls/7779): fix: make hash pattern more strict Co-authored-by: Gusted Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7779 Reviewed-by: Earl Warren Co-authored-by: forgejo-backport-action Co-committed-by: forgejo-backport-action --- modules/markup/html.go | 2 +- modules/markup/html_internal_test.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/markup/html.go b/modules/markup/html.go index 323adf931d..e7be453ea3 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -55,7 +55,7 @@ var ( shortLinkPattern = regexp.MustCompile(`\[\[(.*?)\]\](\w*)`) // anyHashPattern splits url containing SHA into parts - anyHashPattern = regexp.MustCompile(`https?://(?:\S+/){4,5}([0-9a-f]{7,64})(/[-+~_%.a-zA-Z0-9/]+)?(\?[-+~_%\.a-zA-Z0-9=&]+)?(#[-+~_%.a-zA-Z0-9]+)?`) + anyHashPattern = regexp.MustCompile(`https?://(?:(?:\S+/){3,4}(?:commit|tree|blob)/)([0-9a-f]{7,64})(/[-+~_%.a-zA-Z0-9/]+)?(\?[-+~_%\.a-zA-Z0-9=&]+)?(#[-+~_%.a-zA-Z0-9]+)?`) // comparePattern matches "http://domain/org/repo/compare/COMMIT1...COMMIT2#hash" comparePattern = regexp.MustCompile(`https?://(?:\S+/){4,5}([0-9a-f]{7,64})(\.\.\.?)([0-9a-f]{7,64})?(#[-+~_%.a-zA-Z0-9]+)?`) diff --git a/modules/markup/html_internal_test.go b/modules/markup/html_internal_test.go index 6a5d3bfa35..08b1fed505 100644 --- a/modules/markup/html_internal_test.go +++ b/modules/markup/html_internal_test.go @@ -469,6 +469,10 @@ func TestRegExp_anySHA1Pattern(t *testing.T) { for k, v := range testCases { assert.Equal(t, anyHashPattern.FindStringSubmatch(k)[1:], v) } + + for _, v := range []string{"https://codeberg.org/forgejo/forgejo/attachments/774421a1-b0ae-4501-8fba-983874b76811"} { + assert.False(t, anyHashPattern.MatchString(v)) + } } func TestRegExp_shortLinkPattern(t *testing.T) { From a4cb8983350be634448d6cc327666d5db5ac70a0 Mon Sep 17 00:00:00 2001 From: forgejo-backport-action Date: Mon, 5 May 2025 15:25:50 +0000 Subject: [PATCH 03/10] [v11.0/forgejo] fix(api): document `is_system_webhook` field (#7786) **Backport:** https://codeberg.org/forgejo/forgejo/pulls/7784 - Document that `is_system_webhook` field is accepted for the `POST /admin/hooks` endpoint. Co-authored-by: Gusted Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7786 Co-authored-by: forgejo-backport-action Co-committed-by: forgejo-backport-action --- modules/structs/hook.go | 3 ++- templates/swagger/v1_json.tmpl | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/structs/hook.go b/modules/structs/hook.go index 1665dc4da6..28c2e00588 100644 --- a/modules/structs/hook.go +++ b/modules/structs/hook.go @@ -53,7 +53,8 @@ type CreateHookOption struct { BranchFilter string `json:"branch_filter" binding:"GlobPattern"` AuthorizationHeader string `json:"authorization_header"` // default: false - Active bool `json:"active"` + Active bool `json:"active"` + IsSystemWebhook bool `json:"is_system_webhook"` } // EditHookOption options when modify one hook diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index a16deb61a8..9aa2195a0c 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -22178,6 +22178,10 @@ }, "x-go-name": "Events" }, + "is_system_webhook": { + "type": "boolean", + "x-go-name": "IsSystemWebhook" + }, "type": { "type": "string", "enum": [ From 738ec94b8f0e13bb05eed7d435151a3bca062217 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 14 May 2025 12:26:38 +0000 Subject: [PATCH 04/10] Update module github.com/msteinert/pam/v2 to v2.1.0 (v11.0/forgejo) (#7858) Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7858 Reviewed-by: Gusted Co-authored-by: Renovate Bot Co-committed-by: Renovate Bot --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 8a4cfbbc9b..73debaadf8 100644 --- a/go.mod +++ b/go.mod @@ -76,7 +76,7 @@ require ( github.com/mholt/archiver/v3 v3.5.1 github.com/microcosm-cc/bluemonday v1.0.27 github.com/minio/minio-go/v7 v7.0.88 - github.com/msteinert/pam/v2 v2.0.0 + github.com/msteinert/pam/v2 v2.1.0 github.com/nektos/act v0.2.52 github.com/niklasfasching/go-org v1.7.0 github.com/olivere/elastic/v7 v7.0.32 diff --git a/go.sum b/go.sum index aa81c2cbb7..7f255a8425 100644 --- a/go.sum +++ b/go.sum @@ -429,8 +429,8 @@ github.com/mrjones/oauth v0.0.0-20190623134757-126b35219450 h1:j2kD3MT1z4PXCiUll github.com/mrjones/oauth v0.0.0-20190623134757-126b35219450/go.mod h1:skjdDftzkFALcuGzYSklqYd8gvat6F1gZJ4YPVbkZpM= github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM= github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw= -github.com/msteinert/pam/v2 v2.0.0 h1:jnObb8MT6jvMbmrUQO5J/puTUjxy7Av+55zVJRJsCyE= -github.com/msteinert/pam/v2 v2.0.0/go.mod h1:KT28NNIcDFf3PcBmNI2mIGO4zZJ+9RSs/At2PB3IDVc= +github.com/msteinert/pam/v2 v2.1.0 h1:er5F9TKV5nGFuTt12ubtqPHEUdeBwReP7vd3wovidGY= +github.com/msteinert/pam/v2 v2.1.0/go.mod h1:KT28NNIcDFf3PcBmNI2mIGO4zZJ+9RSs/At2PB3IDVc= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/niklasfasching/go-org v1.7.0 h1:vyMdcMWWTe/XmANk19F4k8XGBYg0GQ/gJGMimOjGMek= From fe55ddcdaf239cc88ffc7b1d1d07742db96858bb Mon Sep 17 00:00:00 2001 From: 0ko <0ko@noreply.codeberg.org> Date: Wed, 14 May 2025 23:13:50 +0000 Subject: [PATCH 05/10] fix(ui): improve force-push compare line layout (#7746) On large screens, use grid to force right position of the button. On small screens, just left it hang out wherever it fits. It's not possible to not make it hide behind mergebox while keeping `float`, and with grid it would overflow too much. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7746 Reviewed-by: Otto Co-authored-by: 0ko <0ko@noreply.codeberg.org> Co-committed-by: 0ko <0ko@noreply.codeberg.org> (cherry picked from commit 0383e2e15a666561fae429061c7c54bfaae89ea7) --- templates/repo/issue/view_content/comments.tmpl | 17 ++++++++++------- web_src/css/repo.css | 13 ++++++++----- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index f7d4f7c96e..9eb9307f9f 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -549,18 +549,21 @@
{{svg "octicon-repo-push"}} - {{template "shared/user/authorlink" .Poster}} {{if .IsForcePush}} - {{ctx.Locale.Tr "repo.issues.force_push_codes" $.Issue.PullRequest.HeadBranch (ShortSha .OldCommit) ($.Issue.Repo.CommitLink .OldCommit) (ShortSha .NewCommit) ($.Issue.Repo.CommitLink .NewCommit) $createdStr "ui sha"}} + + + {{template "shared/user/authorlink" .Poster}} + {{ctx.Locale.Tr "repo.issues.force_push_codes" $.Issue.PullRequest.HeadBranch (ShortSha .OldCommit) ($.Issue.Repo.CommitLink .OldCommit) (ShortSha .NewCommit) ($.Issue.Repo.CommitLink .NewCommit) $createdStr "ui sha"}} + + {{if $.Issue.PullRequest.BaseRepo.Name}} + {{ctx.Locale.Tr "repo.issues.force_push_compare"}} + {{end}} + {{else}} + {{template "shared/user/authorlink" .Poster}} {{ctx.Locale.TrN (len .Commits) "repo.issues.push_commit_1" "repo.issues.push_commits_n" (len .Commits) $createdStr}} {{end}} - {{if and .IsForcePush $.Issue.PullRequest.BaseRepo.Name}} - - {{ctx.Locale.Tr "repo.issues.force_push_compare"}} - - {{end}}
{{if not .IsForcePush}} {{template "repo/commits_list_small" dict "comment" . "root" $}} diff --git a/web_src/css/repo.css b/web_src/css/repo.css index f498a992ed..42ff9079f6 100644 --- a/web_src/css/repo.css +++ b/web_src/css/repo.css @@ -904,15 +904,18 @@ td .commit-summary { background: var(--color-orange-badge-hover-bg) !important; } -.repository.view.issue .comment-list .timeline-item .comparebox { - line-height: 32px; - vertical-align: middle; +@media (min-width: 768px) { + .repository.view.issue .comment-list .timeline-item .forced-push { + display: grid; + grid-auto-flow: column; + column-gap: 1rem; + } } -.repository.view.issue .comment-list .timeline-item .comparebox .compare.label { +.repository.view.issue .comment-list .timeline-item .compare.label { font-size: 1rem; - margin: 0; border: 1px solid var(--color-light-border); + height: fit-content; } @media (max-width: 767.98px) { From da267ab00e68509630a46117e5e273c8ef994edc Mon Sep 17 00:00:00 2001 From: forgejo-backport-action Date: Fri, 16 May 2025 12:39:59 +0000 Subject: [PATCH 06/10] [v11.0/forgejo] fix: Remove "create branch" button on mirrored repos (#7869) **Backport:** https://codeberg.org/forgejo/forgejo/pulls/7640 Currently, if you have a mirrored repo, the button on the "branches" page to create a new branch is available to be pressed. Once you name your new branch and click submit, you get a 404 page that doesn't explain what went wrong. As new branch creation is not supported on mirrored repos, let's just take that button away if the repo is a mirror. This is already done for archived repos, so we just need to add another check. Fixes #7639. Co-authored-by: John Moon Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7869 Reviewed-by: Otto Co-authored-by: forgejo-backport-action Co-committed-by: forgejo-backport-action --- models/fixtures/repository.yml | 1 + templates/repo/branch/list.tmpl | 4 ++-- tests/integration/repo_branch_test.go | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/models/fixtures/repository.yml b/models/fixtures/repository.yml index f7aaad1f31..0ba4d06e14 100644 --- a/models/fixtures/repository.yml +++ b/models/fixtures/repository.yml @@ -132,6 +132,7 @@ owner_name: org3 lower_name: repo5 name: repo5 + default_branch: master num_watches: 0 num_stars: 0 num_forks: 0 diff --git a/templates/repo/branch/list.tmpl b/templates/repo/branch/list.tmpl index c60017ba87..fe945324ea 100644 --- a/templates/repo/branch/list.tmpl +++ b/templates/repo/branch/list.tmpl @@ -30,7 +30,7 @@

{{svg "octicon-git-commit" 16 "tw-mr-1"}}{{ShortSha .DefaultBranchBranch.DBBranch.CommitID}} · {{RenderCommitMessage $.Context .DefaultBranchBranch.DBBranch.CommitMessage (.Repository.ComposeMetas ctx)}} · {{ctx.Locale.Tr "org.repo_updated" (DateUtils.TimeSince .DefaultBranchBranch.DBBranch.CommitTime)}}{{if .DefaultBranchBranch.DBBranch.Pusher}}  {{template "shared/user/avatarlink" dict "user" .DefaultBranchBranch.DBBranch.Pusher}}{{template "shared/user/namelink" .DefaultBranchBranch.DBBranch.Pusher}}{{end}}

- {{if and $.IsWriter (not $.Repository.IsArchived) (not .IsDeleted)}} + {{if and $.IsWriter (not $.Repository.IsArchived) (not $.Repository.IsMirror) (not .IsDeleted)}}