Use OldRef instead of CommitSHA for DeleteBranch comments (#14604)

Fix #14545

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
tokarchuk/v1.17
zeripath 4 years ago committed by GitHub
parent 98827e99f6
commit 378acc9d96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      models/issue.go
  2. 2
      models/migrations/migrations.go
  3. 14
      models/migrations/v169.go
  4. 2
      templates/repo/issue/view_content/comments.tmpl

@ -749,7 +749,7 @@ func AddDeletePRBranchComment(doer *User, repo *Repository, issueID int64, branc
Doer: doer,
Repo: repo,
Issue: issue,
CommitSHA: branchName,
OldRef: branchName,
}
if _, err = createComment(sess, opts); err != nil {
return err

@ -284,6 +284,8 @@ var migrations = []Migration{
NewMigration("Add user redirect", addUserRedirect),
// v168 -> v169
NewMigration("Recreate user table to fix default values", recreateUserTableToFixDefaultValues),
// v169 -> v170
NewMigration("Update DeleteBranch comments to set the old_ref to the commit_sha", commentTypeDeleteBranchUseOldRef),
}
// GetCurrentDBVersion returns the current db version

@ -0,0 +1,14 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package migrations
import (
"xorm.io/xorm"
)
func commentTypeDeleteBranchUseOldRef(x *xorm.Engine) error {
_, err := x.Exec("UPDATE comment SET old_ref = commit_sha, commit_sha = '' WHERE type = 11")
return err
}

@ -251,7 +251,7 @@
</a>
<span class="text grey">
<a class="author" href="{{.Poster.HomeLink}}">{{.Poster.GetDisplayName}}</a>
{{$.i18n.Tr "repo.issues.delete_branch_at" (.CommitSHA|Escape) $createdStr | Safe}}
{{$.i18n.Tr "repo.issues.delete_branch_at" (.OldRef|Escape) $createdStr | Safe}}
</span>
</div>
{{else if eq .Type 12}}

Loading…
Cancel
Save