summaryrefslogtreecommitdiffstats
path: root/models/issue.go
diff options
context:
space:
mode:
authorGusted <williamzijl7@hotmail.com>2021-11-19 09:54:31 +0000
committerGitHub <noreply@github.com>2021-11-19 17:54:31 +0800
commit381e131fc8d1a3d93002dfbbf853d9d4aab2c547 (patch)
tree941bd7b8682d7fc9d1818a786ec507ac54206ec2 /models/issue.go
parent00448ebe9184ccfe9e2fd7f48f9b266ae91d6415 (diff)
downloadgitea-381e131fc8d1a3d93002dfbbf853d9d4aab2c547.tar.gz
gitea-381e131fc8d1a3d93002dfbbf853d9d4aab2c547.zip
Added comment for changing issue ref (#17672)
* Added comment for changing issue ref - Add a comment when someone changes the ref(erence?) of a issue.
Diffstat (limited to 'models/issue.go')
-rw-r--r--models/issue.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/models/issue.go b/models/issue.go
index 288163707a..ef31f416ad 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -753,6 +753,24 @@ func (issue *Issue) ChangeRef(doer *User, oldRef string) (err error) {
return fmt.Errorf("updateIssueCols: %v", err)
}
+ if err = issue.loadRepo(db.GetEngine(ctx)); err != nil {
+ return fmt.Errorf("loadRepo: %v", err)
+ }
+ oldRefFriendly := strings.TrimPrefix(oldRef, "refs/heads/")
+ newRefFriendly := strings.TrimPrefix(issue.Ref, "refs/heads/")
+
+ opts := &CreateCommentOptions{
+ Type: CommentTypeChangeIssueRef,
+ Doer: doer,
+ Repo: issue.Repo,
+ Issue: issue,
+ OldRef: oldRefFriendly,
+ NewRef: newRefFriendly,
+ }
+ if _, err = createComment(db.GetEngine(ctx), opts); err != nil {
+ return fmt.Errorf("createComment: %v", err)
+ }
+
return committer.Commit()
}