fix: Do not offer duplicating a PR for a recently pushed branch

Fixes #6187.
This commit is contained in:
Antonin Delpeuch 2024-12-06 23:42:14 +01:00
parent e248179333
commit 4973d23ef8
2 changed files with 42 additions and 4 deletions

View file

@ -417,10 +417,13 @@ 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).