Skip to content

Commit 051ca4b

Browse files
claire1618Claire.Nicholas
and
Claire.Nicholas
authored
feat(delete event): add functionality for delete event (#520)
* feat: adding functionality for a new delete event * fix: pulling in most recent types * fixing things * fix: go get * go mod tidy --------- Co-authored-by: Claire.Nicholas <[email protected]>
1 parent 167b010 commit 051ca4b

File tree

4 files changed

+29
-18
lines changed

4 files changed

+29
-18
lines changed

action/repo/add.go

+7
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ func populateEvents(r *library.Repo, events []string) {
122122
r.SetAllowComment(true)
123123
comment.SetCreated(true)
124124
comment.SetEdited(true)
125+
case constants.EventDelete:
126+
push.SetDeleteBranch(true)
127+
push.SetDeleteTag(true)
125128
case constants.EventPull + ":" + constants.ActionOpened:
126129
pull.SetOpened(true)
127130
case constants.EventPull + ":" + constants.ActionEdited:
@@ -134,6 +137,10 @@ func populateEvents(r *library.Repo, events []string) {
134137
comment.SetCreated(true)
135138
case constants.EventComment + ":" + constants.ActionEdited:
136139
comment.SetEdited(true)
140+
case constants.EventDelete + ":" + constants.ActionBranch:
141+
push.SetDeleteBranch(true)
142+
case constants.EventDelete + ":" + constants.ActionTag:
143+
push.SetDeleteTag(true)
137144
}
138145
}
139146

action/repo/add_test.go

+10-6
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func TestRepo_populateEvents(t *testing.T) {
166166
}{
167167
{
168168
name: "happy path legacy events",
169-
events: []string{"push", "pull_request", "tag", "deploy", "comment"},
169+
events: []string{"push", "pull_request", "tag", "deploy", "comment", "delete"},
170170
want: &library.Repo{
171171
AllowPush: &tBool,
172172
AllowPull: &tBool,
@@ -175,8 +175,10 @@ func TestRepo_populateEvents(t *testing.T) {
175175
AllowComment: &tBool,
176176
AllowEvents: &library.Events{
177177
Push: &actions.Push{
178-
Branch: &tBool,
179-
Tag: &tBool,
178+
Branch: &tBool,
179+
Tag: &tBool,
180+
DeleteBranch: &tBool,
181+
DeleteTag: &tBool,
180182
},
181183
PullRequest: &actions.Pull{
182184
Opened: &tBool,
@@ -195,7 +197,7 @@ func TestRepo_populateEvents(t *testing.T) {
195197
},
196198
{
197199
name: "action specific",
198-
events: []string{"push:branch", "push:tag", "pull_request:opened", "pull_request:edited", "deployment:created", "comment:created"},
200+
events: []string{"push:branch", "push:tag", "pull_request:opened", "pull_request:edited", "deployment:created", "comment:created", "delete:branch", "delete:tag"},
199201
want: &library.Repo{
200202
AllowPush: &tBool,
201203
AllowPull: &fBool,
@@ -204,8 +206,10 @@ func TestRepo_populateEvents(t *testing.T) {
204206
AllowComment: &fBool,
205207
AllowEvents: &library.Events{
206208
Push: &actions.Push{
207-
Branch: &tBool,
208-
Tag: &tBool,
209+
Branch: &tBool,
210+
Tag: &tBool,
211+
DeleteBranch: &tBool,
212+
DeleteTag: &tBool,
209213
},
210214
PullRequest: &actions.Pull{
211215
Opened: &tBool,

go.mod

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ require (
1010
github.com/dustin/go-humanize v1.0.1
1111
github.com/gin-gonic/gin v1.9.1
1212
github.com/go-git/go-git/v5 v5.11.0
13-
github.com/go-vela/sdk-go v0.22.1-0.20240110210525-4a16c9235b7a
14-
github.com/go-vela/server v0.22.3-0.20240105215421-78eca514b01d
15-
github.com/go-vela/types v0.22.1-0.20240111192144-0d0e22367796
16-
github.com/go-vela/worker v0.22.0
13+
github.com/go-vela/sdk-go v0.22.1-0.20240118151315-18ea1c51b5b2
14+
github.com/go-vela/server v0.22.3-0.20240124164127-136cd544d576
15+
github.com/go-vela/types v0.22.1-0.20240122175704-d058de26b401
16+
github.com/go-vela/worker v0.22.1-0.20240118173944-724912db3b72
1717
github.com/golang-jwt/jwt/v5 v5.2.0
1818
github.com/google/go-cmp v0.6.0
1919
github.com/gosuri/uitable v0.0.4

go.sum

+8-8
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,14 @@ github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg
115115
github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
116116
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
117117
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
118-
github.com/go-vela/sdk-go v0.22.1-0.20240110210525-4a16c9235b7a h1:s95Qx5fPiK2eFJDu4vFudir57fWNt2MvcwP9+zzynTY=
119-
github.com/go-vela/sdk-go v0.22.1-0.20240110210525-4a16c9235b7a/go.mod h1:EVAthIAXxYtP6I/AxbzTJngTtgvLwrNtRLZ39TBqZtg=
120-
github.com/go-vela/server v0.22.3-0.20240105215421-78eca514b01d h1:cxFWuaKJEqn6yrgNTWiPIwwiYg+PvkFzvakJWSFL/rI=
121-
github.com/go-vela/server v0.22.3-0.20240105215421-78eca514b01d/go.mod h1:whH2iqp3dZhBzo3z4AC/g9ChpDX/UO0ig+gZn24u58g=
122-
github.com/go-vela/types v0.22.1-0.20240111192144-0d0e22367796 h1:fjma5QAoncoknvTOp2AL/qYDOt4liWkZS5+sUaCQKJw=
123-
github.com/go-vela/types v0.22.1-0.20240111192144-0d0e22367796/go.mod h1:cax3mW1kVz/ioI8qltZE+wl9rOLgOPdwBIvCooL09e4=
124-
github.com/go-vela/worker v0.22.0 h1:zmGiuykclbd0cfH6XKpCnoeIagYhYt7CJQ/y5HfqjZk=
125-
github.com/go-vela/worker v0.22.0/go.mod h1:ErPzlBEBWgYcinlbscn5q+9iArIuajy1DO+Oe9Ya2NA=
118+
github.com/go-vela/sdk-go v0.22.1-0.20240118151315-18ea1c51b5b2 h1:yM4z4PSY2Jr/edCIFjoQwKbr7W0WNnHAavp4LsHm+IA=
119+
github.com/go-vela/sdk-go v0.22.1-0.20240118151315-18ea1c51b5b2/go.mod h1:EVAthIAXxYtP6I/AxbzTJngTtgvLwrNtRLZ39TBqZtg=
120+
github.com/go-vela/server v0.22.3-0.20240124164127-136cd544d576 h1:GQgYRl6sUJAcSk2BuRcN8nd1uoWGFdZqRafph4Kzvp0=
121+
github.com/go-vela/server v0.22.3-0.20240124164127-136cd544d576/go.mod h1:4fjiQD+7EAMxjJ1/qsnWpCrM7hrssY52aQr9o5T6UKA=
122+
github.com/go-vela/types v0.22.1-0.20240122175704-d058de26b401 h1:LdqaHKseq6EUXIJU0h01p14J2rpXF2oFwKbJtsrdE2Y=
123+
github.com/go-vela/types v0.22.1-0.20240122175704-d058de26b401/go.mod h1:cax3mW1kVz/ioI8qltZE+wl9rOLgOPdwBIvCooL09e4=
124+
github.com/go-vela/worker v0.22.1-0.20240118173944-724912db3b72 h1:nW9WwRN7RMrvpG0VIhizEHlWErvUMbIlOb8K+hDlVzE=
125+
github.com/go-vela/worker v0.22.1-0.20240118173944-724912db3b72/go.mod h1:ErPzlBEBWgYcinlbscn5q+9iArIuajy1DO+Oe9Ya2NA=
126126
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
127127
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
128128
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=

0 commit comments

Comments
 (0)