-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Track assignee for issue #808
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,8 @@ const ( | |
CommentTypeLabel | ||
// Milestone changed | ||
CommentTypeMilestone | ||
// Assignees changed | ||
CommentTypeAssignees | ||
) | ||
|
||
// CommentTag defines comment tag type | ||
|
@@ -55,17 +57,22 @@ const ( | |
|
||
// Comment represents a comment in commit and issue page. | ||
type Comment struct { | ||
ID int64 `xorm:"pk autoincr"` | ||
Type CommentType | ||
PosterID int64 `xorm:"INDEX"` | ||
Poster *User `xorm:"-"` | ||
IssueID int64 `xorm:"INDEX"` | ||
LabelID int64 | ||
Label *Label `xorm:"-"` | ||
OldMilestoneID int64 | ||
MilestoneID int64 | ||
OldMilestone *Milestone `xorm:"-"` | ||
Milestone *Milestone `xorm:"-"` | ||
ID int64 `xorm:"pk autoincr"` | ||
Type CommentType | ||
PosterID int64 `xorm:"INDEX"` | ||
Poster *User `xorm:"-"` | ||
IssueID int64 `xorm:"INDEX"` | ||
LabelID int64 | ||
Label *Label `xorm:"-"` | ||
OldMilestoneID int64 | ||
MilestoneID int64 | ||
OldMilestone *Milestone `xorm:"-"` | ||
Milestone *Milestone `xorm:"-"` | ||
OldAssigneeID int64 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice if we didn't have to have both Would it make sense to simply have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that's a good idea. The names should have meaning for easy maintaining. The memory usage is not very different. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough |
||
AssigneeID int64 | ||
Assignee *User `xorm:"-"` | ||
OldAssignee *User `xorm:"-"` | ||
|
||
CommitID int64 | ||
Line int64 | ||
Content string `xorm:"TEXT"` | ||
|
@@ -240,6 +247,25 @@ func (c *Comment) LoadMilestone() error { | |
return nil | ||
} | ||
|
||
// LoadAssignees if comment.Type is CommentTypeAssignees, then load assignees | ||
func (c *Comment) LoadAssignees() error { | ||
var err error | ||
if c.OldAssigneeID > 0 { | ||
c.OldAssignee, err = getUserByID(x, c.OldAssigneeID) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
if c.AssigneeID > 0 { | ||
c.Assignee, err = getUserByID(x, c.AssigneeID) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
// MailParticipants sends new comment emails to repository watchers | ||
// and mentioned people. | ||
func (c *Comment) MailParticipants(e Engine, opType ActionType, issue *Issue) (err error) { | ||
|
@@ -276,6 +302,8 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err | |
LabelID: LabelID, | ||
OldMilestoneID: opts.OldMilestoneID, | ||
MilestoneID: opts.MilestoneID, | ||
OldAssigneeID: opts.OldAssigneeID, | ||
AssigneeID: opts.AssigneeID, | ||
CommitID: opts.CommitID, | ||
CommitSHA: opts.CommitSHA, | ||
Line: opts.LineNum, | ||
|
@@ -416,6 +444,17 @@ func createMilestoneComment(e *xorm.Session, doer *User, repo *Repository, issue | |
}) | ||
} | ||
|
||
func createAssigneeComment(e *xorm.Session, doer *User, repo *Repository, issue *Issue, oldAssigneeID, assigneeID int64) (*Comment, error) { | ||
return createComment(e, &CreateCommentOptions{ | ||
Type: CommentTypeAssignees, | ||
Doer: doer, | ||
Repo: repo, | ||
Issue: issue, | ||
OldAssigneeID: oldAssigneeID, | ||
AssigneeID: assigneeID, | ||
}) | ||
} | ||
|
||
// CreateCommentOptions defines options for creating comment | ||
type CreateCommentOptions struct { | ||
Type CommentType | ||
|
@@ -426,6 +465,8 @@ type CreateCommentOptions struct { | |
|
||
OldMilestoneID int64 | ||
MilestoneID int64 | ||
OldAssigneeID int64 | ||
AssigneeID int64 | ||
CommitID int64 | ||
CommitSHA string | ||
LineNum int64 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why plural? I would prefer singular for consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because currently Gitea only supports one assignee, but github support many. I think Gitea could support many in future. So I keep it plural for the next PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay