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