summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2016-11-28 21:33:09 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2016-11-28 21:33:09 +0800
commit9fc609ce1717682d85d191002d6f9e15b7c6bdaa (patch)
tree004ee64727eb7b92b607254d00369801cb9f3940 /models
parent9948f0daaacfd647a0fb13bd1a82856d0232fea2 (diff)
downloadgitea-9fc609ce1717682d85d191002d6f9e15b7c6bdaa.tar.gz
gitea-9fc609ce1717682d85d191002d6f9e15b7c6bdaa.zip
golint fixed for models/issue_comment.go
Diffstat (limited to 'models')
-rw-r--r--models/issue_comment.go24
1 files changed, 17 insertions, 7 deletions
diff --git a/models/issue_comment.go b/models/issue_comment.go
index c7aa7e2b13..f0fc22af34 100644
--- a/models/issue_comment.go
+++ b/models/issue_comment.go
@@ -21,6 +21,7 @@ import (
// CommentType defines whether a comment is just a simple comment, an action (like close) or a reference.
type CommentType int
+// Enumerate all the comment types
const (
// Plain comment, can be associated with a commit (CommitID > 0) and a line (LineNum > 0)
CommentTypeComment CommentType = iota
@@ -37,8 +38,10 @@ const (
CommentTypePullRef
)
+// CommentTag defines comment tag type
type CommentTag int
+// Enumerate all the comment tag types
const (
CommentTagNone CommentTag = iota
CommentTagPoster
@@ -72,15 +75,19 @@ type Comment struct {
ShowTag CommentTag `xorm:"-"`
}
+// BeforeInsert will be invoked by XORM before inserting a record
+// representing this object.
func (c *Comment) BeforeInsert() {
c.CreatedUnix = time.Now().Unix()
c.UpdatedUnix = c.CreatedUnix
}
+// BeforeUpdate is invoked from XORM before updating this object.
func (c *Comment) BeforeUpdate() {
c.UpdatedUnix = time.Now().Unix()
}
+// AfterSet is invoked from XORM after setting the value of a field of this object.
func (c *Comment) AfterSet(colName string, _ xorm.Cell) {
var err error
switch colName {
@@ -107,6 +114,7 @@ func (c *Comment) AfterSet(colName string, _ xorm.Cell) {
}
}
+// AfterDelete is invoked from XORM after the object is deleted.
func (c *Comment) AfterDelete() {
_, err := DeleteAttachmentsByComment(c.ID, true)
@@ -115,6 +123,7 @@ func (c *Comment) AfterDelete() {
}
}
+// APIFormat converts a Comment to the api.Comment format
func (c *Comment) APIFormat() *api.Comment {
return &api.Comment{
ID: c.ID,
@@ -137,21 +146,21 @@ func (c *Comment) EventTag() string {
// MailParticipants sends new comment emails to repository watchers
// and mentioned people.
-func (cmt *Comment) MailParticipants(opType ActionType, issue *Issue) (err error) {
- mentions := markdown.FindAllMentions(cmt.Content)
- if err = UpdateIssueMentions(cmt.IssueID, mentions); err != nil {
- return fmt.Errorf("UpdateIssueMentions [%d]: %v", cmt.IssueID, err)
+func (c *Comment) MailParticipants(opType ActionType, issue *Issue) (err error) {
+ mentions := markdown.FindAllMentions(c.Content)
+ if err = UpdateIssueMentions(c.IssueID, mentions); err != nil {
+ return fmt.Errorf("UpdateIssueMentions [%d]: %v", c.IssueID, err)
}
switch opType {
case ActionCommentIssue:
- issue.Content = cmt.Content
+ issue.Content = c.Content
case ActionCloseIssue:
issue.Content = fmt.Sprintf("Closed #%d", issue.Index)
case ActionReopenIssue:
issue.Content = fmt.Sprintf("Reopened #%d", issue.Index)
}
- if err = mailIssueCommentToParticipants(issue, cmt.Poster, mentions); err != nil {
+ if err = mailIssueCommentToParticipants(issue, c.Poster, mentions); err != nil {
log.Error(4, "mailIssueCommentToParticipants: %v", err)
}
@@ -272,6 +281,7 @@ func createStatusComment(e *xorm.Session, doer *User, repo *Repository, issue *I
})
}
+// CreateCommentOptions defines options for creating comment
type CreateCommentOptions struct {
Type CommentType
Doer *User
@@ -374,7 +384,7 @@ func GetCommentsByIssueID(issueID int64) ([]*Comment, error) {
return getCommentsByIssueID(x, issueID)
}
-// GetCommentsByIssueID returns a list of comments of an issue since a given time point.
+// GetCommentsByIssueIDSince returns a list of comments of an issue since a given time point.
func GetCommentsByIssueIDSince(issueID, since int64) ([]*Comment, error) {
return getCommentsByIssueIDSince(x, issueID, since)
}