@@ -427,7 +427,8 @@ type RecentlyPushedNewBranch struct {
427427
428428// FindRecentlyPushedNewBranches return at most 2 new branches pushed by the user in 2 hours which has no opened PRs created
429429// if opts.CommitAfterUnix is 0, we will find the branches that were committed to in the last 2 hours
430- // if opts.ListOptions is not set, we will only display top 2 latest branch
430+ // if opts.ListOptions is not set, we will only display top 2 latest branches.
431+ // Protected branches will be skipped since they are unlikely to be used to create new PRs.
431432func FindRecentlyPushedNewBranches (ctx context.Context , doer * user_model.User , opts * FindRecentlyPushedNewBranchesOptions ) ([]* RecentlyPushedNewBranch , error ) {
432433 if doer == nil {
433434 return []* RecentlyPushedNewBranch {}, nil
@@ -486,6 +487,18 @@ func FindRecentlyPushedNewBranches(ctx context.Context, doer *user_model.User, o
486487 opts .MaxCount = 2
487488 }
488489 for _ , branch := range branches {
490+ // whether the branch is protected
491+ protected , err := IsBranchProtected (ctx , branch .RepoID , branch .Name )
492+ if err != nil {
493+ return nil , fmt .Errorf ("IsBranchProtected: %v" , err )
494+ }
495+ if protected {
496+ // Skip protected branches,
497+ // since updates to protected branches often come from PR merges,
498+ // and they are unlikely to be used to create new PRs.
499+ continue
500+ }
501+
489502 // whether branch have already created PR
490503 count , err := db .GetEngine (ctx ).Table ("pull_request" ).
491504 // we should not only use branch name here, because if there are branches with same name in other repos,
0 commit comments