@@ -52,84 +52,61 @@ func (err ErrCommentNotExist) Unwrap() error {
52
52
// CommentType defines whether a comment is just a simple comment, an action (like close) or a reference.
53
53
type CommentType int
54
54
55
- // define unknown comment type
56
- const (
57
- CommentTypeUnknown CommentType = - 1
58
- )
55
+ // CommentTypeUndefined is used to search for comments of any type
56
+ const CommentTypeUndefined CommentType = - 1
59
57
60
- // Enumerate all the comment types
61
58
const (
62
- // 0 Plain comment, can be associated with a commit (CommitID > 0) and a line (LineNum > 0)
63
- CommentTypeComment CommentType = iota
64
- CommentTypeReopen // 1
65
- CommentTypeClose // 2
66
-
67
- // 3 References.
68
- CommentTypeIssueRef
69
- // 4 Reference from a commit (not part of a pull request)
70
- CommentTypeCommitRef
71
- // 5 Reference from a comment
72
- CommentTypeCommentRef
73
- // 6 Reference from a pull request
74
- CommentTypePullRef
75
- // 7 Labels changed
76
- CommentTypeLabel
77
- // 8 Milestone changed
78
- CommentTypeMilestone
79
- // 9 Assignees changed
80
- CommentTypeAssignees
81
- // 10 Change Title
82
- CommentTypeChangeTitle
83
- // 11 Delete Branch
84
- CommentTypeDeleteBranch
85
- // 12 Start a stopwatch for time tracking
86
- CommentTypeStartTracking
87
- // 13 Stop a stopwatch for time tracking
88
- CommentTypeStopTracking
89
- // 14 Add time manual for time tracking
90
- CommentTypeAddTimeManual
91
- // 15 Cancel a stopwatch for time tracking
92
- CommentTypeCancelTracking
93
- // 16 Added a due date
94
- CommentTypeAddedDeadline
95
- // 17 Modified the due date
96
- CommentTypeModifiedDeadline
97
- // 18 Removed a due date
98
- CommentTypeRemovedDeadline
99
- // 19 Dependency added
100
- CommentTypeAddDependency
101
- // 20 Dependency removed
102
- CommentTypeRemoveDependency
103
- // 21 Comment a line of code
104
- CommentTypeCode
105
- // 22 Reviews a pull request by giving general feedback
106
- CommentTypeReview
107
- // 23 Lock an issue, giving only collaborators access
108
- CommentTypeLock
109
- // 24 Unlocks a previously locked issue
110
- CommentTypeUnlock
111
- // 25 Change pull request's target branch
112
- CommentTypeChangeTargetBranch
113
- // 26 Delete time manual for time tracking
114
- CommentTypeDeleteTimeManual
115
- // 27 add or remove Request from one
116
- CommentTypeReviewRequest
117
- // 28 merge pull request
118
- CommentTypeMergePull
119
- // 29 push to PR head branch
120
- CommentTypePullRequestPush
121
- // 30 Project changed
122
- CommentTypeProject
123
- // 31 Project board changed
124
- CommentTypeProjectBoard
125
- // 32 Dismiss Review
126
- CommentTypeDismissReview
127
- // 33 Change issue ref
128
- CommentTypeChangeIssueRef
129
- // 34 pr was scheduled to auto merge when checks succeed
130
- CommentTypePRScheduledToAutoMerge
131
- // 35 pr was un scheduled to auto merge when checks succeed
132
- CommentTypePRUnScheduledToAutoMerge
59
+ CommentTypeComment CommentType = iota // 0 Plain comment, can be associated with a commit (CommitID > 0) and a line (LineNum > 0)
60
+
61
+ CommentTypeReopen // 1
62
+ CommentTypeClose // 2
63
+
64
+ CommentTypeIssueRef // 3 References.
65
+ CommentTypeCommitRef // 4 Reference from a commit (not part of a pull request)
66
+ CommentTypeCommentRef // 5 Reference from a comment
67
+ CommentTypePullRef // 6 Reference from a pull request
68
+
69
+ CommentTypeLabel // 7 Labels changed
70
+ CommentTypeMilestone // 8 Milestone changed
71
+ CommentTypeAssignees // 9 Assignees changed
72
+ CommentTypeChangeTitle // 10 Change Title
73
+ CommentTypeDeleteBranch // 11 Delete Branch
74
+
75
+ CommentTypeStartTracking // 12 Start a stopwatch for time tracking
76
+ CommentTypeStopTracking // 13 Stop a stopwatch for time tracking
77
+ CommentTypeAddTimeManual // 14 Add time manual for time tracking
78
+ CommentTypeCancelTracking // 15 Cancel a stopwatch for time tracking
79
+ CommentTypeAddedDeadline // 16 Added a due date
80
+ CommentTypeModifiedDeadline // 17 Modified the due date
81
+ CommentTypeRemovedDeadline // 18 Removed a due date
82
+
83
+ CommentTypeAddDependency // 19 Dependency added
84
+ CommentTypeRemoveDependency // 20 Dependency removed
85
+
86
+ CommentTypeCode // 21 Comment a line of code
87
+ CommentTypeReview // 22 Reviews a pull request by giving general feedback
88
+
89
+ CommentTypeLock // 23 Lock an issue, giving only collaborators access
90
+ CommentTypeUnlock // 24 Unlocks a previously locked issue
91
+
92
+ CommentTypeChangeTargetBranch // 25 Change pull request's target branch
93
+
94
+ CommentTypeDeleteTimeManual // 26 Delete time manual for time tracking
95
+
96
+ CommentTypeReviewRequest // 27 add or remove Request from one
97
+ CommentTypeMergePull // 28 merge pull request
98
+ CommentTypePullRequestPush // 29 push to PR head branch
99
+
100
+ CommentTypeProject // 30 Project changed
101
+ CommentTypeProjectBoard // 31 Project board changed
102
+
103
+ CommentTypeDismissReview // 32 Dismiss Review
104
+
105
+ CommentTypeChangeIssueRef // 33 Change issue ref
106
+
107
+ CommentTypePRScheduledToAutoMerge // 34 pr was scheduled to auto merge when checks succeed
108
+ CommentTypePRUnScheduledToAutoMerge // 35 pr was un scheduled to auto merge when checks succeed
109
+
133
110
)
134
111
135
112
var commentStrings = []string {
@@ -181,7 +158,23 @@ func AsCommentType(typeName string) CommentType {
181
158
return CommentType (index )
182
159
}
183
160
}
184
- return CommentTypeUnknown
161
+ return CommentTypeUndefined
162
+ }
163
+
164
+ func (t CommentType ) HasContentSupport () bool {
165
+ switch t {
166
+ case CommentTypeComment , CommentTypeCode , CommentTypeReview :
167
+ return true
168
+ }
169
+ return false
170
+ }
171
+
172
+ func (t CommentType ) HasAttachmentSupport () bool {
173
+ switch t {
174
+ case CommentTypeComment , CommentTypeCode , CommentTypeReview :
175
+ return true
176
+ }
177
+ return false
185
178
}
186
179
187
180
// RoleDescriptor defines comment tag type
@@ -1039,7 +1032,7 @@ func (opts *FindCommentsOptions) ToConds() builder.Cond {
1039
1032
if opts .Before > 0 {
1040
1033
cond = cond .And (builder.Lte {"comment.updated_unix" : opts .Before })
1041
1034
}
1042
- if opts .Type != CommentTypeUnknown {
1035
+ if opts .Type != CommentTypeUndefined {
1043
1036
cond = cond .And (builder.Eq {"comment.type" : opts .Type })
1044
1037
}
1045
1038
if opts .Line != 0 {
0 commit comments