Skip to content

Commit 572aaeb

Browse files
authored
Rename head branch of pull requests when renaming a branch (#31759)
Fix #31716
1 parent 0b7eb38 commit 572aaeb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

models/git/branch.go

+7
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,13 @@ func RenameBranch(ctx context.Context, repo *repo_model.Repository, from, to str
392392
return err
393393
}
394394

395+
// 4.1 Update all not merged pull request head branch name
396+
if _, err = sess.Table("pull_request").Where("head_repo_id=? AND head_branch=? AND has_merged=?",
397+
repo.ID, from, false).
398+
Update(map[string]any{"head_branch": to}); err != nil {
399+
return err
400+
}
401+
395402
// 5. insert renamed branch record
396403
renamedBranch := &RenamedBranch{
397404
RepoID: repo.ID,

0 commit comments

Comments
 (0)