|
| 1 | +// Copyright 2023 The Gitea Authors. All rights reserved. |
| 2 | +// SPDX-License-Identifier: MIT |
| 3 | + |
| 4 | +package activities |
| 5 | + |
| 6 | +import "strconv" |
| 7 | + |
| 8 | +// ActionType represents the type of an action. |
| 9 | +type ActionType int |
| 10 | + |
| 11 | +// Possible action types. |
| 12 | +const ( |
| 13 | + ActionCreateRepo ActionType = iota + 1 // 1 |
| 14 | + ActionRenameRepo // 2 |
| 15 | + ActionStarRepo // 3 |
| 16 | + ActionWatchRepo // 4 |
| 17 | + ActionCommitRepo // 5 |
| 18 | + ActionCreateIssue // 6 |
| 19 | + ActionCreatePullRequest // 7 |
| 20 | + ActionTransferRepo // 8 |
| 21 | + ActionPushTag // 9 |
| 22 | + ActionCommentIssue // 10 |
| 23 | + ActionMergePullRequest // 11 |
| 24 | + ActionCloseIssue // 12 |
| 25 | + ActionReopenIssue // 13 |
| 26 | + ActionClosePullRequest // 14 |
| 27 | + ActionReopenPullRequest // 15 |
| 28 | + ActionDeleteTag // 16 |
| 29 | + ActionDeleteBranch // 17 |
| 30 | + ActionMirrorSyncPush // 18 |
| 31 | + ActionMirrorSyncCreate // 19 |
| 32 | + ActionMirrorSyncDelete // 20 |
| 33 | + ActionApprovePullRequest // 21 |
| 34 | + ActionRejectPullRequest // 22 |
| 35 | + ActionCommentPull // 23 |
| 36 | + ActionPublishRelease // 24 |
| 37 | + ActionPullReviewDismissed // 25 |
| 38 | + ActionPullRequestReadyForReview // 26 |
| 39 | + ActionAutoMergePullRequest // 27 |
| 40 | +) |
| 41 | + |
| 42 | +func (at ActionType) IsActionCreateRepo() bool { |
| 43 | + return at == ActionCreateRepo |
| 44 | +} |
| 45 | + |
| 46 | +func (at ActionType) IsActionRenameRepo() bool { |
| 47 | + return at == ActionRenameRepo |
| 48 | +} |
| 49 | + |
| 50 | +func (at ActionType) IsActionStarRepo() bool { |
| 51 | + return at == ActionStarRepo |
| 52 | +} |
| 53 | + |
| 54 | +func (at ActionType) IsActionWatchRepo() bool { |
| 55 | + return at == ActionWatchRepo |
| 56 | +} |
| 57 | + |
| 58 | +func (at ActionType) IsActionCommitRepo() bool { |
| 59 | + return at == ActionCommitRepo |
| 60 | +} |
| 61 | + |
| 62 | +func (at ActionType) IsActionCreateIssue() bool { |
| 63 | + return at == ActionCreateIssue |
| 64 | +} |
| 65 | + |
| 66 | +func (at ActionType) IsActionCreatePullRequest() bool { |
| 67 | + return at == ActionCreatePullRequest |
| 68 | +} |
| 69 | + |
| 70 | +func (at ActionType) IsActionTransferRepo() bool { |
| 71 | + return at == ActionTransferRepo |
| 72 | +} |
| 73 | + |
| 74 | +func (at ActionType) IsActionPushTag() bool { |
| 75 | + return at == ActionPushTag |
| 76 | +} |
| 77 | + |
| 78 | +func (at ActionType) IsActionCommentIssue() bool { |
| 79 | + return at == ActionCommentIssue |
| 80 | +} |
| 81 | + |
| 82 | +func (at ActionType) IsActionMergePullRequest() bool { |
| 83 | + return at == ActionMergePullRequest |
| 84 | +} |
| 85 | + |
| 86 | +func (at ActionType) IsActionCloseIssue() bool { |
| 87 | + return at == ActionCloseIssue |
| 88 | +} |
| 89 | + |
| 90 | +func (at ActionType) IsActionReopenIssue() bool { |
| 91 | + return at == ActionReopenIssue |
| 92 | +} |
| 93 | + |
| 94 | +func (at ActionType) IsActionClosePullRequest() bool { |
| 95 | + return at == ActionClosePullRequest |
| 96 | +} |
| 97 | + |
| 98 | +func (at ActionType) IsActionReopenPullRequest() bool { |
| 99 | + return at == ActionReopenPullRequest |
| 100 | +} |
| 101 | + |
| 102 | +func (at ActionType) IsActionDeleteTag() bool { |
| 103 | + return at == ActionDeleteTag |
| 104 | +} |
| 105 | + |
| 106 | +func (at ActionType) IsActionDeleteBranch() bool { |
| 107 | + return at == ActionDeleteBranch |
| 108 | +} |
| 109 | + |
| 110 | +func (at ActionType) IsActionMirrorSyncPush() bool { |
| 111 | + return at == ActionMirrorSyncPush |
| 112 | +} |
| 113 | + |
| 114 | +func (at ActionType) IsActionMirrorSyncCreate() bool { |
| 115 | + return at == ActionMirrorSyncCreate |
| 116 | +} |
| 117 | + |
| 118 | +func (at ActionType) IsActionMirrorSyncDelete() bool { |
| 119 | + return at == ActionMirrorSyncDelete |
| 120 | +} |
| 121 | + |
| 122 | +func (at ActionType) IsActionApprovePullRequest() bool { |
| 123 | + return at == ActionApprovePullRequest |
| 124 | +} |
| 125 | + |
| 126 | +func (at ActionType) IsActionRejectPullRequest() bool { |
| 127 | + return at == ActionRejectPullRequest |
| 128 | +} |
| 129 | + |
| 130 | +func (at ActionType) IsActionCommentPull() bool { |
| 131 | + return at == ActionCommentPull |
| 132 | +} |
| 133 | + |
| 134 | +func (at ActionType) IsActionPublishRelease() bool { |
| 135 | + return at == ActionPublishRelease |
| 136 | +} |
| 137 | + |
| 138 | +func (at ActionType) IsActionPullReviewDismissed() bool { |
| 139 | + return at == ActionPullReviewDismissed |
| 140 | +} |
| 141 | + |
| 142 | +func (at ActionType) IsActionPullRequestReadyForReview() bool { |
| 143 | + return at == ActionPullRequestReadyForReview |
| 144 | +} |
| 145 | + |
| 146 | +func (at ActionType) IsActionAutoMergePullRequest() bool { |
| 147 | + return at == ActionAutoMergePullRequest |
| 148 | +} |
| 149 | + |
| 150 | +func (at ActionType) String() string { |
| 151 | + switch at { |
| 152 | + case ActionCreateRepo: |
| 153 | + return "create_repo" |
| 154 | + case ActionRenameRepo: |
| 155 | + return "rename_repo" |
| 156 | + case ActionStarRepo: |
| 157 | + return "star_repo" |
| 158 | + case ActionWatchRepo: |
| 159 | + return "watch_repo" |
| 160 | + case ActionCommitRepo: |
| 161 | + return "commit_repo" |
| 162 | + case ActionCreateIssue: |
| 163 | + return "create_issue" |
| 164 | + case ActionCreatePullRequest: |
| 165 | + return "create_pull_request" |
| 166 | + case ActionTransferRepo: |
| 167 | + return "transfer_repo" |
| 168 | + case ActionPushTag: |
| 169 | + return "push_tag" |
| 170 | + case ActionCommentIssue: |
| 171 | + return "comment_issue" |
| 172 | + case ActionMergePullRequest: |
| 173 | + return "merge_pull_request" |
| 174 | + case ActionCloseIssue: |
| 175 | + return "close_issue" |
| 176 | + case ActionReopenIssue: |
| 177 | + return "reopen_issue" |
| 178 | + case ActionClosePullRequest: |
| 179 | + return "close_pull_request" |
| 180 | + case ActionReopenPullRequest: |
| 181 | + return "reopen_pull_request" |
| 182 | + case ActionDeleteTag: |
| 183 | + return "delete_tag" |
| 184 | + case ActionDeleteBranch: |
| 185 | + return "delete_branch" |
| 186 | + case ActionMirrorSyncPush: |
| 187 | + return "mirror_sync_push" |
| 188 | + case ActionMirrorSyncCreate: |
| 189 | + return "mirror_sync_create" |
| 190 | + case ActionMirrorSyncDelete: |
| 191 | + return "mirror_sync_delete" |
| 192 | + case ActionApprovePullRequest: |
| 193 | + return "approve_pull_request" |
| 194 | + case ActionRejectPullRequest: |
| 195 | + return "reject_pull_request" |
| 196 | + case ActionCommentPull: |
| 197 | + return "comment_pull" |
| 198 | + case ActionPublishRelease: |
| 199 | + return "publish_release" |
| 200 | + case ActionPullReviewDismissed: |
| 201 | + return "pull_review_dismissed" |
| 202 | + case ActionPullRequestReadyForReview: |
| 203 | + return "pull_request_ready_for_review" |
| 204 | + case ActionAutoMergePullRequest: |
| 205 | + return "auto_merge_pull_request" |
| 206 | + default: |
| 207 | + return "action-" + strconv.Itoa(int(at)) |
| 208 | + } |
| 209 | +} |
0 commit comments