Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit07db743

Browse files
committed
Display "new pull request" alert also on issue & PR lists
1 parent4e10adc commit07db743

File tree

4 files changed

+70
-52
lines changed

4 files changed

+70
-52
lines changed

‎routers/web/repo/issue_list.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"code.gitea.io/gitea/services/convert"
3232
issue_service"code.gitea.io/gitea/services/issue"
3333
pull_service"code.gitea.io/gitea/services/pull"
34+
"code.gitea.io/gitea/services/uinotification"
3435
)
3536

3637
funcretrieveProjectsForIssueList(ctx*context.Context,repo*repo_model.Repository) {
@@ -789,5 +790,7 @@ func Issues(ctx *context.Context) {
789790

790791
ctx.Data["CanWriteIssuesOrPulls"]=ctx.Repo.CanWriteIssuesOrPulls(isPullList)
791792

793+
uinotification.PrepareRecentlyPushedNewBranches(ctx)
794+
792795
ctx.HTML(http.StatusOK,tplIssues)
793796
}

‎routers/web/repo/view_home.go‎

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515

1616
"code.gitea.io/gitea/models/db"
1717
git_model"code.gitea.io/gitea/models/git"
18-
access_model"code.gitea.io/gitea/models/perm/access"
1918
repo_model"code.gitea.io/gitea/models/repo"
2019
unit_model"code.gitea.io/gitea/models/unit"
2120
user_model"code.gitea.io/gitea/models/user"
@@ -31,6 +30,7 @@ import (
3130
"code.gitea.io/gitea/routers/web/feed"
3231
"code.gitea.io/gitea/services/context"
3332
repo_service"code.gitea.io/gitea/services/repository"
33+
"code.gitea.io/gitea/services/uinotification"
3434
)
3535

3636
funccheckOutdatedBranch(ctx*context.Context) {
@@ -196,56 +196,6 @@ func prepareUpstreamDivergingInfo(ctx *context.Context) {
196196
ctx.Data["UpstreamDivergingInfo"]=upstreamDivergingInfo
197197
}
198198

199-
funcprepareRecentlyPushedNewBranches(ctx*context.Context) {
200-
ifctx.Doer!=nil {
201-
iferr:=ctx.Repo.Repository.GetBaseRepo(ctx);err!=nil {
202-
ctx.ServerError("GetBaseRepo",err)
203-
return
204-
}
205-
206-
opts:=&git_model.FindRecentlyPushedNewBranchesOptions{
207-
Repo:ctx.Repo.Repository,
208-
BaseRepo:ctx.Repo.Repository,
209-
}
210-
ifctx.Repo.Repository.IsFork {
211-
opts.BaseRepo=ctx.Repo.Repository.BaseRepo
212-
}
213-
214-
baseRepoPerm,err:=access_model.GetUserRepoPermission(ctx,opts.BaseRepo,ctx.Doer)
215-
iferr!=nil {
216-
ctx.ServerError("GetUserRepoPermission",err)
217-
return
218-
}
219-
220-
if!opts.Repo.IsMirror&&!opts.BaseRepo.IsMirror&&
221-
opts.BaseRepo.UnitEnabled(ctx,unit_model.TypePullRequests)&&
222-
baseRepoPerm.CanRead(unit_model.TypePullRequests) {
223-
varfinalBranches []*git_model.RecentlyPushedNewBranch
224-
branches,err:=git_model.FindRecentlyPushedNewBranches(ctx,ctx.Doer,opts)
225-
iferr!=nil {
226-
log.Error("FindRecentlyPushedNewBranches failed: %v",err)
227-
}
228-
229-
for_,branch:=rangebranches {
230-
divergingInfo,err:=repo_service.GetBranchDivergingInfo(ctx,
231-
branch.BranchRepo,branch.BranchName,// "base" repo for diverging info
232-
opts.BaseRepo,opts.BaseRepo.DefaultBranch,// "head" repo for diverging info
233-
)
234-
iferr!=nil {
235-
log.Error("GetBranchDivergingInfo failed: %v",err)
236-
continue
237-
}
238-
branchRepoHasNewCommits:=divergingInfo.BaseHasNewCommits
239-
baseRepoCommitsBehind:=divergingInfo.HeadCommitsBehind
240-
ifbranchRepoHasNewCommits||baseRepoCommitsBehind>0 {
241-
finalBranches=append(finalBranches,branch)
242-
}
243-
}
244-
ctx.Data["RecentlyPushedNewBranches"]=finalBranches
245-
}
246-
}
247-
}
248-
249199
funcupdateContextRepoEmptyAndStatus(ctx*context.Context,emptybool,status repo_model.RepositoryStatus) {
250200
ifctx.Repo.Repository.IsEmpty==empty&&ctx.Repo.Repository.Status==status {
251201
return
@@ -471,7 +421,7 @@ func Home(ctx *context.Context) {
471421
prepareHomeSidebarRepoTopics,
472422
checkOutdatedBranch,
473423
prepareToRenderDirOrFile(entry),
474-
prepareRecentlyPushedNewBranches,
424+
uinotification.PrepareRecentlyPushedNewBranches,
475425
}
476426

477427
ifisTreePathRoot {

‎services/uinotification/branch.go‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package uinotification
5+
6+
import (
7+
git_model"code.gitea.io/gitea/models/git"
8+
access_model"code.gitea.io/gitea/models/perm/access"
9+
unit_model"code.gitea.io/gitea/models/unit"
10+
"code.gitea.io/gitea/modules/log"
11+
"code.gitea.io/gitea/services/context"
12+
repo_service"code.gitea.io/gitea/services/repository"
13+
)
14+
15+
funcPrepareRecentlyPushedNewBranches(ctx*context.Context) {
16+
ifctx.Doer!=nil {
17+
iferr:=ctx.Repo.Repository.GetBaseRepo(ctx);err!=nil {
18+
ctx.ServerError("GetBaseRepo",err)
19+
return
20+
}
21+
22+
opts:=&git_model.FindRecentlyPushedNewBranchesOptions{
23+
Repo:ctx.Repo.Repository,
24+
BaseRepo:ctx.Repo.Repository,
25+
}
26+
ifctx.Repo.Repository.IsFork {
27+
opts.BaseRepo=ctx.Repo.Repository.BaseRepo
28+
}
29+
30+
baseRepoPerm,err:=access_model.GetUserRepoPermission(ctx,opts.BaseRepo,ctx.Doer)
31+
iferr!=nil {
32+
ctx.ServerError("GetUserRepoPermission",err)
33+
return
34+
}
35+
36+
if!opts.Repo.IsMirror&&!opts.BaseRepo.IsMirror&&
37+
opts.BaseRepo.UnitEnabled(ctx,unit_model.TypePullRequests)&&
38+
baseRepoPerm.CanRead(unit_model.TypePullRequests) {
39+
varfinalBranches []*git_model.RecentlyPushedNewBranch
40+
branches,err:=git_model.FindRecentlyPushedNewBranches(ctx,ctx.Doer,opts)
41+
iferr!=nil {
42+
log.Error("FindRecentlyPushedNewBranches failed: %v",err)
43+
}
44+
45+
for_,branch:=rangebranches {
46+
divergingInfo,err:=repo_service.GetBranchDivergingInfo(ctx,
47+
branch.BranchRepo,branch.BranchName,// "base" repo for diverging info
48+
opts.BaseRepo,opts.BaseRepo.DefaultBranch,// "head" repo for diverging info
49+
)
50+
iferr!=nil {
51+
log.Error("GetBranchDivergingInfo failed: %v",err)
52+
continue
53+
}
54+
branchRepoHasNewCommits:=divergingInfo.BaseHasNewCommits
55+
baseRepoCommitsBehind:=divergingInfo.HeadCommitsBehind
56+
ifbranchRepoHasNewCommits||baseRepoCommitsBehind>0 {
57+
finalBranches=append(finalBranches,branch)
58+
}
59+
}
60+
ctx.Data["RecentlyPushedNewBranches"]=finalBranches
61+
}
62+
}
63+
}

‎templates/repo/issue/list.tmpl‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<div class="ui container">
55
{{template "base/alert" .}}
66

7+
{{template "repo/code/recently_pushed_new_branches" .}}
8+
79
{{if .PinnedIssues}}
810
<div id="issue-pins" {{if .IsRepoAdmin}}data-is-repo-admin{{end}}>
911
{{range .PinnedIssues}}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp