aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authoryp05327 <576951401@qq.com>2024-05-23 13:14:26 +0900
committerGitHub <noreply@github.com>2024-05-23 04:14:26 +0000
commit564fef1e208290f2ead151cdc95ed846f93178c7 (patch)
tree0ea3d3b63f84d6069733aeb11d8905c472192783 /routers
parent14ed06d675a7d69ef40fdd5a7f63327d294cfe67 (diff)
downloadgitea-564fef1e208290f2ead151cdc95ed846f93178c7.tar.gz
gitea-564fef1e208290f2ead151cdc95ed846f93178c7.zip
Fix wrong display of recently pushed notification (#25812) (#31043)
Backport #25812 ~~ps: removed some new codes in `tests/integration/pull_merge_test.go`~~ --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'routers')
-rw-r--r--routers/web/repo/view.go26
1 files changed, 19 insertions, 7 deletions
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go
index e4e6201c24..e1498c0d58 100644
--- a/routers/web/repo/view.go
+++ b/routers/web/repo/view.go
@@ -29,6 +29,7 @@ import (
"code.gitea.io/gitea/models/db"
git_model "code.gitea.io/gitea/models/git"
issue_model "code.gitea.io/gitea/models/issues"
+ access_model "code.gitea.io/gitea/models/perm/access"
repo_model "code.gitea.io/gitea/models/repo"
unit_model "code.gitea.io/gitea/models/unit"
user_model "code.gitea.io/gitea/models/user"
@@ -1027,15 +1028,26 @@ func renderHomeCode(ctx *context.Context) {
return
}
- showRecentlyPushedNewBranches := true
- if ctx.Repo.Repository.IsMirror ||
- !ctx.Repo.Repository.UnitEnabled(ctx, unit_model.TypePullRequests) {
- showRecentlyPushedNewBranches = false
+ opts := &git_model.FindRecentlyPushedNewBranchesOptions{
+ Repo: ctx.Repo.Repository,
+ BaseRepo: ctx.Repo.Repository,
}
- if showRecentlyPushedNewBranches {
- ctx.Data["RecentlyPushedNewBranches"], err = git_model.FindRecentlyPushedNewBranches(ctx, ctx.Repo.Repository.ID, ctx.Doer.ID, ctx.Repo.Repository.DefaultBranch)
+ if ctx.Repo.Repository.IsFork {
+ opts.BaseRepo = ctx.Repo.Repository.BaseRepo
+ }
+
+ baseRepoPerm, err := access_model.GetUserRepoPermission(ctx, opts.BaseRepo, ctx.Doer)
+ if err != nil {
+ ctx.ServerError("GetUserRepoPermission", err)
+ return
+ }
+
+ if !opts.Repo.IsMirror && !opts.BaseRepo.IsMirror &&
+ opts.BaseRepo.UnitEnabled(ctx, unit_model.TypePullRequests) &&
+ baseRepoPerm.CanRead(unit_model.TypePullRequests) {
+ ctx.Data["RecentlyPushedNewBranches"], err = git_model.FindRecentlyPushedNewBranches(ctx, ctx.Doer, opts)
if err != nil {
- ctx.ServerError("GetRecentlyPushedBranches", err)
+ ctx.ServerError("FindRecentlyPushedNewBranches", err)
return
}
}