mirror of
https://gitcode.com/gitea/gitea.git
synced 2025-06-05 12:06:41 +08:00
Add delete branch track on pull request comments (#888)
* add delete branch track on pull request comments * don't change vendor
This commit is contained in:
@ -685,6 +685,24 @@ func (issue *Issue) ChangeTitle(doer *User, title string) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddDeletePRBranchComment adds delete branch comment for pull request issue
|
||||
func AddDeletePRBranchComment(doer *User, repo *Repository, issueID int64, branchName string) error {
|
||||
issue, err := getIssueByID(x, issueID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sess := x.NewSession()
|
||||
defer sess.Close()
|
||||
if err := sess.Begin(); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := createDeleteBranchComment(sess, doer, repo, issue, branchName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return sess.Commit()
|
||||
}
|
||||
|
||||
// ChangeContent changes issue content, as the given user.
|
||||
func (issue *Issue) ChangeContent(doer *User, content string) (err error) {
|
||||
oldContent := issue.Content
|
||||
|
@ -44,6 +44,8 @@ const (
|
||||
CommentTypeAssignees
|
||||
// Change Title
|
||||
CommentTypeChangeTitle
|
||||
// Delete Branch
|
||||
CommentTypeDeleteBranch
|
||||
)
|
||||
|
||||
// CommentTag defines comment tag type
|
||||
@ -472,6 +474,16 @@ func createChangeTitleComment(e *xorm.Session, doer *User, repo *Repository, iss
|
||||
})
|
||||
}
|
||||
|
||||
func createDeleteBranchComment(e *xorm.Session, doer *User, repo *Repository, issue *Issue, branchName string) (*Comment, error) {
|
||||
return createComment(e, &CreateCommentOptions{
|
||||
Type: CommentTypeDeleteBranch,
|
||||
Doer: doer,
|
||||
Repo: repo,
|
||||
Issue: issue,
|
||||
CommitSHA: branchName,
|
||||
})
|
||||
}
|
||||
|
||||
// CreateCommentOptions defines options for creating comment
|
||||
type CreateCommentOptions struct {
|
||||
Type CommentType
|
||||
|
Reference in New Issue
Block a user