Skip to content

Commit 43ada65

Browse files
authored
remove unused method and rename createcommentWithNoAction (#9367)
1 parent 67b316a commit 43ada65

File tree

9 files changed

+17
-89
lines changed

9 files changed

+17
-89
lines changed

models/issue.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ func (issue *Issue) changeStatus(e *xorm.Session, doer *User, isClosed bool) (*C
664664
cmtType = CommentTypeReopen
665665
}
666666

667-
return createCommentWithNoAction(e, &CreateCommentOptions{
667+
return createComment(e, &CreateCommentOptions{
668668
Type: cmtType,
669669
Doer: doer,
670670
Repo: issue.Repo,
@@ -724,7 +724,7 @@ func (issue *Issue) ChangeTitle(doer *User, oldTitle string) (err error) {
724724
OldTitle: oldTitle,
725725
NewTitle: issue.Title,
726726
}
727-
if _, err = createCommentWithNoAction(sess, opts); err != nil {
727+
if _, err = createComment(sess, opts); err != nil {
728728
return fmt.Errorf("createComment: %v", err)
729729
}
730730
if err = issue.addCrossReferences(sess, doer, true); err != nil {
@@ -752,7 +752,7 @@ func AddDeletePRBranchComment(doer *User, repo *Repository, issueID int64, branc
752752
Issue: issue,
753753
CommitSHA: branchName,
754754
}
755-
if _, err = createCommentWithNoAction(sess, opts); err != nil {
755+
if _, err = createComment(sess, opts); err != nil {
756756
return err
757757
}
758758

@@ -894,7 +894,7 @@ func newIssue(e *xorm.Session, doer *User, opts NewIssueOptions) (err error) {
894894
OldMilestoneID: 0,
895895
MilestoneID: opts.Issue.MilestoneID,
896896
}
897-
if _, err = createCommentWithNoAction(e, opts); err != nil {
897+
if _, err = createComment(e, opts); err != nil {
898898
return err
899899
}
900900
}

models/issue_assignees.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func (issue *Issue) toggleAssignee(sess *xorm.Session, doer *User, assigneeID in
140140
AssigneeID: assigneeID,
141141
}
142142
// Comment
143-
comment, err = createCommentWithNoAction(sess, opts)
143+
comment, err = createComment(sess, opts)
144144
if err != nil {
145145
return false, nil, fmt.Errorf("createComment: %v", err)
146146
}

models/issue_comment.go

Lines changed: 5 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ func (c *Comment) CodeCommentURL() string {
495495
return fmt.Sprintf("%s/files#%s", c.Issue.HTMLURL(), c.HashTag())
496496
}
497497

498-
func createCommentWithNoAction(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err error) {
498+
func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err error) {
499499
var LabelID int64
500500
if opts.Label != nil {
501501
LabelID = opts.Label.ID
@@ -589,55 +589,6 @@ func updateCommentInfos(e *xorm.Session, opts *CreateCommentOptions, comment *Co
589589
return updateIssueCols(e, opts.Issue, "updated_unix")
590590
}
591591

592-
func sendCreateCommentAction(e *xorm.Session, opts *CreateCommentOptions, comment *Comment) (err error) {
593-
// Compose comment action, could be plain comment, close or reopen issue/pull request.
594-
// This object will be used to notify watchers in the end of function.
595-
act := &Action{
596-
ActUserID: opts.Doer.ID,
597-
ActUser: opts.Doer,
598-
Content: fmt.Sprintf("%d|%s", opts.Issue.Index, strings.Split(opts.Content, "\n")[0]),
599-
RepoID: opts.Repo.ID,
600-
Repo: opts.Repo,
601-
Comment: comment,
602-
CommentID: comment.ID,
603-
IsPrivate: opts.Repo.IsPrivate,
604-
}
605-
// Check comment type.
606-
switch opts.Type {
607-
case CommentTypeCode:
608-
if comment.ReviewID != 0 {
609-
if comment.Review == nil {
610-
if err := comment.loadReview(e); err != nil {
611-
return err
612-
}
613-
}
614-
if comment.Review.Type <= ReviewTypePending {
615-
return nil
616-
}
617-
}
618-
fallthrough
619-
case CommentTypeComment:
620-
act.OpType = ActionCommentIssue
621-
case CommentTypeReopen:
622-
act.OpType = ActionReopenIssue
623-
if opts.Issue.IsPull {
624-
act.OpType = ActionReopenPullRequest
625-
}
626-
case CommentTypeClose:
627-
act.OpType = ActionCloseIssue
628-
if opts.Issue.IsPull {
629-
act.OpType = ActionClosePullRequest
630-
}
631-
}
632-
// Notify watchers for whatever action comes in, ignore if no action type.
633-
if act.OpType > 0 {
634-
if err = notifyWatchers(e, act); err != nil {
635-
log.Error("notifyWatchers: %v", err)
636-
}
637-
}
638-
return nil
639-
}
640-
641592
func createDeadlineComment(e *xorm.Session, doer *User, issue *Issue, newDeadlineUnix timeutil.TimeStamp) (*Comment, error) {
642593
var content string
643594
var commentType CommentType
@@ -667,7 +618,7 @@ func createDeadlineComment(e *xorm.Session, doer *User, issue *Issue, newDeadlin
667618
Issue: issue,
668619
Content: content,
669620
}
670-
comment, err := createCommentWithNoAction(e, opts)
621+
comment, err := createComment(e, opts)
671622
if err != nil {
672623
return nil, err
673624
}
@@ -692,7 +643,7 @@ func createIssueDependencyComment(e *xorm.Session, doer *User, issue *Issue, dep
692643
Issue: issue,
693644
DependentIssueID: dependentIssue.ID,
694645
}
695-
if _, err = createCommentWithNoAction(e, opts); err != nil {
646+
if _, err = createComment(e, opts); err != nil {
696647
return
697648
}
698649

@@ -703,7 +654,7 @@ func createIssueDependencyComment(e *xorm.Session, doer *User, issue *Issue, dep
703654
Issue: dependentIssue,
704655
DependentIssueID: issue.ID,
705656
}
706-
_, err = createCommentWithNoAction(e, opts)
657+
_, err = createComment(e, opts)
707658
return
708659
}
709660

@@ -745,27 +696,7 @@ func CreateComment(opts *CreateCommentOptions) (comment *Comment, err error) {
745696
return nil, err
746697
}
747698

748-
comment, err = createCommentWithNoAction(sess, opts)
749-
if err != nil {
750-
return nil, err
751-
}
752-
753-
if err = sess.Commit(); err != nil {
754-
return nil, err
755-
}
756-
757-
return comment, nil
758-
}
759-
760-
// CreateCommentWithNoAction creates comment of issue or commit with no action created
761-
func CreateCommentWithNoAction(opts *CreateCommentOptions) (comment *Comment, err error) {
762-
sess := x.NewSession()
763-
defer sess.Close()
764-
if err = sess.Begin(); err != nil {
765-
return nil, err
766-
}
767-
768-
comment, err = createCommentWithNoAction(sess, opts)
699+
comment, err = createComment(sess, opts)
769700
if err != nil {
770701
return nil, err
771702
}

models/issue_label.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ func newIssueLabel(e *xorm.Session, issue *Issue, label *Label, doer *User) (err
433433
Label: label,
434434
Content: "1",
435435
}
436-
if _, err = createCommentWithNoAction(e, opts); err != nil {
436+
if _, err = createComment(e, opts); err != nil {
437437
return err
438438
}
439439

@@ -509,7 +509,7 @@ func deleteIssueLabel(e *xorm.Session, issue *Issue, label *Label, doer *User) (
509509
Issue: issue,
510510
Label: label,
511511
}
512-
if _, err = createCommentWithNoAction(e, opts); err != nil {
512+
if _, err = createComment(e, opts); err != nil {
513513
return err
514514
}
515515

models/issue_lock.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func updateIssueLock(opts *IssueLockOptions, lock bool) error {
5252
Type: commentType,
5353
Content: opts.Reason,
5454
}
55-
if _, err := createCommentWithNoAction(sess, opt); err != nil {
55+
if _, err := createComment(sess, opt); err != nil {
5656
return err
5757
}
5858

models/issue_milestone.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ func changeMilestoneAssign(e *xorm.Session, doer *User, issue *Issue, oldMilesto
422422
OldMilestoneID: oldMilestoneID,
423423
MilestoneID: issue.MilestoneID,
424424
}
425-
if _, err := createCommentWithNoAction(e, opts); err != nil {
425+
if _, err := createComment(e, opts); err != nil {
426426
return err
427427
}
428428
}

models/issue_xref.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,10 @@ func (issue *Issue) createCrossReferences(e *xorm.Session, ctx *crossReferencesC
127127
RefAction: xref.Action,
128128
RefIsPull: ctx.OrigIssue.IsPull,
129129
}
130-
comment, err := createCommentWithNoAction(e, opts)
130+
_, err := createComment(e, opts)
131131
if err != nil {
132132
return err
133133
}
134-
if err = sendCreateCommentAction(e, opts, comment); err != nil {
135-
return err
136-
}
137134
}
138135
return nil
139136
}

models/review.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ func SubmitReview(doer *User, issue *Issue, reviewType ReviewType, content strin
324324
}
325325
}
326326

327-
comm, err := createCommentWithNoAction(sess, &CreateCommentOptions{
327+
comm, err := createComment(sess, &CreateCommentOptions{
328328
Type: CommentTypeReview,
329329
Doer: doer,
330330
Content: review.Content,

services/pull/review.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func createCodeComment(doer *models.User, repo *models.Repository, issue *models
144144
}
145145
patch = gitdiff.CutDiffAroundLine(patchBuf, int64((&models.Comment{Line: line}).UnsignedLine()), line < 0, setting.UI.CodeCommentLines)
146146
}
147-
return models.CreateCommentWithNoAction(&models.CreateCommentOptions{
147+
return models.CreateComment(&models.CreateCommentOptions{
148148
Type: models.CommentTypeCode,
149149
Doer: doer,
150150
Repo: repo,

0 commit comments

Comments
 (0)