summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorGiteabot <teabot@gitea.io>2024-08-04 14:37:02 +0800
committerGitHub <noreply@github.com>2024-08-04 14:37:02 +0800
commitb1266ed18227ae36d110c9c6a6024233521d0ae0 (patch)
tree694b4623e5542664957551cf4679c020d2f95d10 /models
parent82003a3b47898b7235de175858801b0b9239525d (diff)
downloadgitea-b1266ed18227ae36d110c9c6a6024233521d0ae0.tar.gz
gitea-b1266ed18227ae36d110c9c6a6024233521d0ae0.zip
Rename head branch of pull requests when renaming a branch (#31759) (#31774)
Diffstat (limited to 'models')
-rw-r--r--models/git/branch.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/models/git/branch.go b/models/git/branch.go
index c315d921ff..fa0afb04f0 100644
--- a/models/git/branch.go
+++ b/models/git/branch.go
@@ -392,6 +392,13 @@ func RenameBranch(ctx context.Context, repo *repo_model.Repository, from, to str
return err
}
+ // 4.1 Update all not merged pull request head branch name
+ if _, err = sess.Table("pull_request").Where("head_repo_id=? AND head_branch=? AND has_merged=?",
+ repo.ID, from, false).
+ Update(map[string]any{"head_branch": to}); err != nil {
+ return err
+ }
+
// 5. insert renamed branch record
renamedBranch := &RenamedBranch{
RepoID: repo.ID,