mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-07-07 16:00:04 +02:00
Merge pull request 'fix: Do not offer duplicating a PR for a recently pushed branch' (#6191) from wetneb/forgejo:6187-recent-branches into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6191 Reviewed-by: Otto <otto@codeberg.org>
This commit is contained in:
commit
c1d882df5b
2 changed files with 43 additions and 5 deletions
|
@ -417,15 +417,18 @@ func FindRecentlyPushedNewBranches(ctx context.Context, repoID, userID int64, ex
|
|||
branches := make(BranchList, 0, 2)
|
||||
subQuery := builder.Select("head_branch").From("pull_request").
|
||||
InnerJoin("issue", "issue.id = pull_request.issue_id").
|
||||
Where(builder.Eq{
|
||||
"pull_request.head_repo_id": repoID,
|
||||
"issue.is_closed": false,
|
||||
})
|
||||
Where(builder.And(
|
||||
builder.Eq{"pull_request.head_repo_id": repoID},
|
||||
builder.Or(
|
||||
builder.Eq{"pull_request.has_merged": true},
|
||||
builder.Eq{"issue.is_closed": false},
|
||||
),
|
||||
))
|
||||
err := db.GetEngine(ctx).
|
||||
Where("pusher_id=? AND is_deleted=?", userID, false).
|
||||
And("name <> ?", excludeBranchName).
|
||||
And("repo_id = ?", repoID).
|
||||
And("commit_time >= ?", time.Now().Add(-time.Hour*6).Unix()).
|
||||
And("commit_time >= ?", time.Now().Add(-time.Minute*30).Unix()).
|
||||
NotIn("name", subQuery).
|
||||
OrderBy("branch.commit_time DESC").
|
||||
Limit(2).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue