@@ -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"
@@ -28,6 +27,7 @@ import (
2827 "code.gitea.io/gitea/modules/setting"
2928 "code.gitea.io/gitea/modules/svg"
3029 "code.gitea.io/gitea/modules/util"
30+ "code.gitea.io/gitea/routers/utils"
3131 "code.gitea.io/gitea/routers/web/feed"
3232 "code.gitea.io/gitea/services/context"
3333 repo_service "code.gitea.io/gitea/services/repository"
@@ -196,56 +196,6 @@ func prepareUpstreamDivergingInfo(ctx *context.Context) {
196196 ctx .Data ["UpstreamDivergingInfo" ] = upstreamDivergingInfo
197197}
198198
199- func prepareRecentlyPushedNewBranches (ctx * context.Context ) {
200- if ctx .Doer != nil {
201- if err := 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- if ctx .Repo .Repository .IsFork {
211- opts .BaseRepo = ctx .Repo .Repository .BaseRepo
212- }
213-
214- baseRepoPerm , err := access_model .GetUserRepoPermission (ctx , opts .BaseRepo , ctx .Doer )
215- if err != 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- var finalBranches []* git_model.RecentlyPushedNewBranch
224- branches , err := git_model .FindRecentlyPushedNewBranches (ctx , ctx .Doer , opts )
225- if err != nil {
226- log .Error ("FindRecentlyPushedNewBranches failed: %v" , err )
227- }
228-
229- for _ , branch := range branches {
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- if err != nil {
235- log .Error ("GetBranchDivergingInfo failed: %v" , err )
236- continue
237- }
238- branchRepoHasNewCommits := divergingInfo .BaseHasNewCommits
239- baseRepoCommitsBehind := divergingInfo .HeadCommitsBehind
240- if branchRepoHasNewCommits || baseRepoCommitsBehind > 0 {
241- finalBranches = append (finalBranches , branch )
242- }
243- }
244- ctx .Data ["RecentlyPushedNewBranches" ] = finalBranches
245- }
246- }
247- }
248-
249199func updateContextRepoEmptyAndStatus (ctx * context.Context , empty bool , status repo_model.RepositoryStatus ) {
250200 if ctx .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+ utils . PrepareRecentlyPushedNewBranches ,
475425 }
476426
477427 if isTreePathRoot {
0 commit comments