@ -52,84 +52,61 @@ func (err ErrCommentNotExist) Unwrap() error {
// CommentType defines whether a comment is just a simple comment, an action (like close) or a reference.
// CommentType defines whether a comment is just a simple comment, an action (like close) or a reference.
type CommentType int
type CommentType int
// define unknown comment type
// CommentTypeUndefined is used to search for comments of any type
const (
const CommentTypeUndefined CommentType = - 1
CommentTypeUnknown CommentType = - 1
)
// Enumerate all the comment types
const (
const (
// 0 Plain comment, can be associated with a commit (CommitID > 0) and a line (LineNum > 0)
CommentTypeComment CommentType = iota // 0 Plain comment, can be associated with a commit (CommitID > 0) and a line (LineNum > 0)
CommentTypeComment CommentType = iota
CommentTypeReopen // 1
CommentTypeReopen // 1
CommentTypeClose // 2
CommentTypeClose // 2
// 3 References.
CommentTypeIssueRef // 3 References.
CommentTypeIssueRef
CommentTypeCommitRef // 4 Reference from a commit (not part of a pull request)
// 4 Reference from a commit (not part of a pull request)
CommentTypeCommentRef // 5 Reference from a comment
CommentTypeCommitRef
CommentTypePullRef // 6 Reference from a pull request
// 5 Reference from a comment
CommentTypeCommentRef
CommentTypeLabel // 7 Labels changed
// 6 Reference from a pull request
CommentTypeMilestone // 8 Milestone changed
CommentTypePullRef
CommentTypeAssignees // 9 Assignees changed
// 7 Labels changed
CommentTypeChangeTitle // 10 Change Title
CommentTypeLabel
CommentTypeDeleteBranch // 11 Delete Branch
// 8 Milestone changed
CommentTypeMilestone
CommentTypeStartTracking // 12 Start a stopwatch for time tracking
// 9 Assignees changed
CommentTypeStopTracking // 13 Stop a stopwatch for time tracking
CommentTypeAssignees
CommentTypeAddTimeManual // 14 Add time manual for time tracking
// 10 Change Title
CommentTypeCancelTracking // 15 Cancel a stopwatch for time tracking
CommentTypeChangeTitle
CommentTypeAddedDeadline // 16 Added a due date
// 11 Delete Branch
CommentTypeModifiedDeadline // 17 Modified the due date
CommentTypeDeleteBranch
CommentTypeRemovedDeadline // 18 Removed a due date
// 12 Start a stopwatch for time tracking
CommentTypeStartTracking
CommentTypeAddDependency // 19 Dependency added
// 13 Stop a stopwatch for time tracking
CommentTypeRemoveDependency // 20 Dependency removed
CommentTypeStopTracking
// 14 Add time manual for time tracking
CommentTypeCode // 21 Comment a line of code
CommentTypeAddTimeManual
CommentTypeReview // 22 Reviews a pull request by giving general feedback
// 15 Cancel a stopwatch for time tracking
CommentTypeCancelTracking
CommentTypeLock // 23 Lock an issue, giving only collaborators access
// 16 Added a due date
CommentTypeUnlock // 24 Unlocks a previously locked issue
CommentTypeAddedDeadline
// 17 Modified the due date
CommentTypeChangeTargetBranch // 25 Change pull request's target branch
CommentTypeModifiedDeadline
// 18 Removed a due date
CommentTypeDeleteTimeManual // 26 Delete time manual for time tracking
CommentTypeRemovedDeadline
// 19 Dependency added
CommentTypeReviewRequest // 27 add or remove Request from one
CommentTypeAddDependency
CommentTypeMergePull // 28 merge pull request
// 20 Dependency removed
CommentTypePullRequestPush // 29 push to PR head branch
CommentTypeRemoveDependency
// 21 Comment a line of code
CommentTypeProject // 30 Project changed
CommentTypeCode
CommentTypeProjectBoard // 31 Project board changed
// 22 Reviews a pull request by giving general feedback
CommentTypeReview
CommentTypeDismissReview // 32 Dismiss Review
// 23 Lock an issue, giving only collaborators access
CommentTypeLock
CommentTypeChangeIssueRef // 33 Change issue ref
// 24 Unlocks a previously locked issue
CommentTypeUnlock
CommentTypePRScheduledToAutoMerge // 34 pr was scheduled to auto merge when checks succeed
// 25 Change pull request's target branch
CommentTypePRUnScheduledToAutoMerge // 35 pr was un scheduled to auto merge when checks succeed
CommentTypeChangeTargetBranch
// 26 Delete time manual for time tracking
CommentTypeDeleteTimeManual
// 27 add or remove Request from one
CommentTypeReviewRequest
// 28 merge pull request
CommentTypeMergePull
// 29 push to PR head branch
CommentTypePullRequestPush
// 30 Project changed
CommentTypeProject
// 31 Project board changed
CommentTypeProjectBoard
// 32 Dismiss Review
CommentTypeDismissReview
// 33 Change issue ref
CommentTypeChangeIssueRef
// 34 pr was scheduled to auto merge when checks succeed
CommentTypePRScheduledToAutoMerge
// 35 pr was un scheduled to auto merge when checks succeed
CommentTypePRUnScheduledToAutoMerge
)
)
var commentStrings = [ ] string {
var commentStrings = [ ] string {
@ -181,7 +158,23 @@ func AsCommentType(typeName string) CommentType {
return CommentType ( index )
return CommentType ( index )
}
}
}
}
return CommentTypeUnknown
return CommentTypeUndefined
}
func ( t CommentType ) HasContentSupport ( ) bool {
switch t {
case CommentTypeComment , CommentTypeCode , CommentTypeReview :
return true
}
return false
}
func ( t CommentType ) HasAttachmentSupport ( ) bool {
switch t {
case CommentTypeComment , CommentTypeCode , CommentTypeReview :
return true
}
return false
}
}
// RoleDescriptor defines comment tag type
// RoleDescriptor defines comment tag type
@ -1039,7 +1032,7 @@ func (opts *FindCommentsOptions) ToConds() builder.Cond {
if opts . Before > 0 {
if opts . Before > 0 {
cond = cond . And ( builder . Lte { "comment.updated_unix" : opts . Before } )
cond = cond . And ( builder . Lte { "comment.updated_unix" : opts . Before } )
}
}
if opts . Type != CommentTypeUn known {
if opts . Type != CommentTypeUn defined {
cond = cond . And ( builder . Eq { "comment.type" : opts . Type } )
cond = cond . And ( builder . Eq { "comment.type" : opts . Type } )
}
}
if opts . Line != 0 {
if opts . Line != 0 {