@@ -427,7 +427,8 @@ type RecentlyPushedNewBranch struct {
427
427
428
428
// FindRecentlyPushedNewBranches return at most 2 new branches pushed by the user in 2 hours which has no opened PRs created
429
429
// 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.
431
432
func FindRecentlyPushedNewBranches (ctx context.Context , doer * user_model.User , opts * FindRecentlyPushedNewBranchesOptions ) ([]* RecentlyPushedNewBranch , error ) {
432
433
if doer == nil {
433
434
return []* RecentlyPushedNewBranch {}, nil
@@ -486,6 +487,18 @@ func FindRecentlyPushedNewBranches(ctx context.Context, doer *user_model.User, o
486
487
opts .MaxCount = 2
487
488
}
488
489
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
+
489
502
// whether branch have already created PR
490
503
count , err := db .GetEngine (ctx ).Table ("pull_request" ).
491
504
// we should not only use branch name here, because if there are branches with same name in other repos,
0 commit comments