@@ -66,6 +66,10 @@ const (
6666 CommentTypeModifiedDeadline
6767 // Removed a due date
6868 CommentTypeRemovedDeadline
69+ // Dependency added
70+ CommentTypeAddDependency
71+ //Dependency removed
72+ CommentTypeRemoveDependency
6973)
7074
7175// CommentTag defines comment tag type
@@ -81,23 +85,25 @@ const (
8185
8286// Comment represents a comment in commit and issue page.
8387type Comment struct {
84- ID int64 `xorm:"pk autoincr"`
85- Type CommentType
86- PosterID int64 `xorm:"INDEX"`
87- Poster * User `xorm:"-"`
88- IssueID int64 `xorm:"INDEX"`
89- Issue * Issue `xorm:"-"`
90- LabelID int64
91- Label * Label `xorm:"-"`
92- OldMilestoneID int64
93- MilestoneID int64
94- OldMilestone * Milestone `xorm:"-"`
95- Milestone * Milestone `xorm:"-"`
96- AssigneeID int64
97- RemovedAssignee bool
98- Assignee * User `xorm:"-"`
99- OldTitle string
100- NewTitle string
88+ ID int64 `xorm:"pk autoincr"`
89+ Type CommentType
90+ PosterID int64 `xorm:"INDEX"`
91+ Poster * User `xorm:"-"`
92+ IssueID int64 `xorm:"INDEX"`
93+ Issue * Issue `xorm:"-"`
94+ LabelID int64
95+ Label * Label `xorm:"-"`
96+ OldMilestoneID int64
97+ MilestoneID int64
98+ OldMilestone * Milestone `xorm:"-"`
99+ Milestone * Milestone `xorm:"-"`
100+ AssigneeID int64
101+ RemovedAssignee bool
102+ Assignee * User `xorm:"-"`
103+ OldTitle string
104+ NewTitle string
105+ DependentIssueID int64
106+ DependentIssue * Issue `xorm:"-"`
101107
102108 CommitID int64
103109 Line int64
@@ -281,6 +287,15 @@ func (c *Comment) LoadAssigneeUser() error {
281287 return nil
282288}
283289
290+ // LoadDepIssueDetails loads Dependent Issue Details
291+ func (c * Comment ) LoadDepIssueDetails () (err error ) {
292+ if c .DependentIssueID <= 0 || c .DependentIssue != nil {
293+ return nil
294+ }
295+ c .DependentIssue , err = getIssueByID (x , c .DependentIssueID )
296+ return err
297+ }
298+
284299// MailParticipants sends new comment emails to repository watchers
285300// and mentioned people.
286301func (c * Comment ) MailParticipants (e Engine , opType ActionType , issue * Issue ) (err error ) {
@@ -332,22 +347,24 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
332347 if opts .Label != nil {
333348 LabelID = opts .Label .ID
334349 }
350+
335351 comment := & Comment {
336- Type : opts .Type ,
337- PosterID : opts .Doer .ID ,
338- Poster : opts .Doer ,
339- IssueID : opts .Issue .ID ,
340- LabelID : LabelID ,
341- OldMilestoneID : opts .OldMilestoneID ,
342- MilestoneID : opts .MilestoneID ,
343- RemovedAssignee : opts .RemovedAssignee ,
344- AssigneeID : opts .AssigneeID ,
345- CommitID : opts .CommitID ,
346- CommitSHA : opts .CommitSHA ,
347- Line : opts .LineNum ,
348- Content : opts .Content ,
349- OldTitle : opts .OldTitle ,
350- NewTitle : opts .NewTitle ,
352+ Type : opts .Type ,
353+ PosterID : opts .Doer .ID ,
354+ Poster : opts .Doer ,
355+ IssueID : opts .Issue .ID ,
356+ LabelID : LabelID ,
357+ OldMilestoneID : opts .OldMilestoneID ,
358+ MilestoneID : opts .MilestoneID ,
359+ RemovedAssignee : opts .RemovedAssignee ,
360+ AssigneeID : opts .AssigneeID ,
361+ CommitID : opts .CommitID ,
362+ CommitSHA : opts .CommitSHA ,
363+ Line : opts .LineNum ,
364+ Content : opts .Content ,
365+ OldTitle : opts .OldTitle ,
366+ NewTitle : opts .NewTitle ,
367+ DependentIssueID : opts .DependentIssueID ,
351368 }
352369 if _ , err = e .Insert (comment ); err != nil {
353370 return nil , err
@@ -549,6 +566,39 @@ func createDeleteBranchComment(e *xorm.Session, doer *User, repo *Repository, is
549566 })
550567}
551568
569+ // Creates issue dependency comment
570+ func createIssueDependencyComment (e * xorm.Session , doer * User , issue * Issue , dependentIssue * Issue , add bool ) (err error ) {
571+ cType := CommentTypeAddDependency
572+ if ! add {
573+ cType = CommentTypeRemoveDependency
574+ }
575+
576+ // Make two comments, one in each issue
577+ _ , err = createComment (e , & CreateCommentOptions {
578+ Type : cType ,
579+ Doer : doer ,
580+ Repo : issue .Repo ,
581+ Issue : issue ,
582+ DependentIssueID : dependentIssue .ID ,
583+ })
584+ if err != nil {
585+ return
586+ }
587+
588+ _ , err = createComment (e , & CreateCommentOptions {
589+ Type : cType ,
590+ Doer : doer ,
591+ Repo : issue .Repo ,
592+ Issue : dependentIssue ,
593+ DependentIssueID : issue .ID ,
594+ })
595+ if err != nil {
596+ return
597+ }
598+
599+ return
600+ }
601+
552602// CreateCommentOptions defines options for creating comment
553603type CreateCommentOptions struct {
554604 Type CommentType
@@ -557,17 +607,18 @@ type CreateCommentOptions struct {
557607 Issue * Issue
558608 Label * Label
559609
560- OldMilestoneID int64
561- MilestoneID int64
562- AssigneeID int64
563- RemovedAssignee bool
564- OldTitle string
565- NewTitle string
566- CommitID int64
567- CommitSHA string
568- LineNum int64
569- Content string
570- Attachments []string // UUIDs of attachments
610+ DependentIssueID int64
611+ OldMilestoneID int64
612+ MilestoneID int64
613+ AssigneeID int64
614+ RemovedAssignee bool
615+ OldTitle string
616+ NewTitle string
617+ CommitID int64
618+ CommitSHA string
619+ LineNum int64
620+ Content string
621+ Attachments []string // UUIDs of attachments
571622}
572623
573624// CreateComment creates comment of issue or commit.
0 commit comments