Skip to content

Commit c5c7726

Browse files
authored
fix(yaml/ruleset): fix unmarshal PR event to use synchronize, not synchronized (go-vela#257)
* fix(constants): change synchronized to synchronize to support legacy pr unmarshal * fix tests * change variable name too
1 parent ccad28d commit c5c7726

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

constants/action.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ const (
1818
// ActionRenamed defines the action for renaming a repository.
1919
ActionRenamed = "renamed"
2020

21-
// ActionSynchronized defines the action for the synchronizing of pull requests.
22-
ActionSynchronized = "synchronized"
21+
// ActionSynchronize defines the action for the synchronizing of pull requests.
22+
ActionSynchronize = "synchronize"
2323
)

yaml/build_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func TestYaml_Build_UnmarshalYAML(t *testing.T) {
137137
Name: "install",
138138
Pull: "always",
139139
Ruleset: Ruleset{
140-
If: Rules{Event: []string{"push", "pull_request:opened", "pull_request:synchronized", "pull_request:edited"}},
140+
If: Rules{Event: []string{"push", "pull_request:opened", "pull_request:synchronize", "pull_request:edited"}},
141141
Matcher: "filepath",
142142
Operator: "and",
143143
},
@@ -166,7 +166,7 @@ func TestYaml_Build_UnmarshalYAML(t *testing.T) {
166166
Image: "openjdk:latest",
167167
Pull: "always",
168168
Ruleset: Ruleset{
169-
If: Rules{Event: []string{"push", "pull_request:opened", "pull_request:synchronized"}},
169+
If: Rules{Event: []string{"push", "pull_request:opened", "pull_request:synchronize"}},
170170
Matcher: "filepath",
171171
Operator: "and",
172172
},
@@ -195,7 +195,7 @@ func TestYaml_Build_UnmarshalYAML(t *testing.T) {
195195
Image: "openjdk:latest",
196196
Pull: "always",
197197
Ruleset: Ruleset{
198-
If: Rules{Event: []string{"push", "pull_request:opened", "pull_request:synchronized"}},
198+
If: Rules{Event: []string{"push", "pull_request:opened", "pull_request:synchronize"}},
199199
Matcher: "filepath",
200200
Operator: "and",
201201
},
@@ -225,7 +225,7 @@ func TestYaml_Build_UnmarshalYAML(t *testing.T) {
225225
Image: "plugins/docker:18.09",
226226
Pull: "always",
227227
Ruleset: Ruleset{
228-
If: Rules{Event: []string{"push", "pull_request:opened", "pull_request:synchronized"}},
228+
If: Rules{Event: []string{"push", "pull_request:opened", "pull_request:synchronize"}},
229229
Matcher: "filepath",
230230
Operator: "and",
231231
},
@@ -346,7 +346,7 @@ func TestYaml_Build_UnmarshalYAML(t *testing.T) {
346346
Name: "install",
347347
Pull: "always",
348348
Ruleset: Ruleset{
349-
If: Rules{Event: []string{"push", "pull_request:opened", "pull_request:synchronized"}},
349+
If: Rules{Event: []string{"push", "pull_request:opened", "pull_request:synchronize"}},
350350
Matcher: "filepath",
351351
Operator: "and",
352352
},
@@ -381,7 +381,7 @@ func TestYaml_Build_UnmarshalYAML(t *testing.T) {
381381
Image: "openjdk:latest",
382382
Pull: "always",
383383
Ruleset: Ruleset{
384-
If: Rules{Event: []string{"push", "pull_request:opened", "pull_request:synchronized"}},
384+
If: Rules{Event: []string{"push", "pull_request:opened", "pull_request:synchronize"}},
385385
Matcher: "filepath",
386386
Operator: "and",
387387
},
@@ -416,7 +416,7 @@ func TestYaml_Build_UnmarshalYAML(t *testing.T) {
416416
Image: "openjdk:latest",
417417
Pull: "always",
418418
Ruleset: Ruleset{
419-
If: Rules{Event: []string{"push", "pull_request:opened", "pull_request:synchronized"}},
419+
If: Rules{Event: []string{"push", "pull_request:opened", "pull_request:synchronize"}},
420420
Matcher: "filepath",
421421
Operator: "and",
422422
},
@@ -460,7 +460,7 @@ func TestYaml_Build_UnmarshalYAML(t *testing.T) {
460460
Name: "install",
461461
Pull: "always",
462462
Ruleset: Ruleset{
463-
If: Rules{Event: []string{"push", "pull_request:opened", "pull_request:synchronized"}},
463+
If: Rules{Event: []string{"push", "pull_request:opened", "pull_request:synchronize"}},
464464
Matcher: "filepath",
465465
Operator: "and",
466466
},
@@ -489,7 +489,7 @@ func TestYaml_Build_UnmarshalYAML(t *testing.T) {
489489
Image: "openjdk:latest",
490490
Pull: "always",
491491
Ruleset: Ruleset{
492-
If: Rules{Event: []string{"push", "pull_request:opened", "pull_request:synchronized"}},
492+
If: Rules{Event: []string{"push", "pull_request:opened", "pull_request:synchronize"}},
493493
Matcher: "filepath",
494494
Operator: "and",
495495
},
@@ -518,7 +518,7 @@ func TestYaml_Build_UnmarshalYAML(t *testing.T) {
518518
Image: "openjdk:latest",
519519
Pull: "always",
520520
Ruleset: Ruleset{
521-
If: Rules{Event: []string{"push", "pull_request:opened", "pull_request:synchronized"}},
521+
If: Rules{Event: []string{"push", "pull_request:opened", "pull_request:synchronize"}},
522522
Matcher: "filepath",
523523
Operator: "and",
524524
},
@@ -566,7 +566,7 @@ func TestYaml_Build_UnmarshalYAML(t *testing.T) {
566566
Name: "install",
567567
Pull: "always",
568568
Ruleset: Ruleset{
569-
If: Rules{Event: []string{"push", "pull_request:opened", "pull_request:synchronized"}},
569+
If: Rules{Event: []string{"push", "pull_request:opened", "pull_request:synchronize"}},
570570
Matcher: "filepath",
571571
Operator: "and",
572572
},

yaml/ruleset.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ func (r *Rules) UnmarshalYAML(unmarshal func(interface{}) error) error {
148148

149149
for _, e := range rules.Event {
150150
switch e {
151-
// backwards compatibility - pull_request = pull_request:opened + pull_request:synchronized
151+
// backwards compatibility - pull_request = pull_request:opened + pull_request:synchronize
152152
// comment = comment:created + comment:edited
153153
case constants.EventPull:
154154
events = append(events,
155155
constants.EventPull+":"+constants.ActionOpened,
156-
constants.EventPull+":"+constants.ActionSynchronized)
156+
constants.EventPull+":"+constants.ActionSynchronize)
157157
case constants.EventComment:
158158
events = append(events,
159159
constants.EventComment+":"+constants.ActionCreated,

yaml/ruleset_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func TestYaml_Ruleset_UnmarshalYAML(t *testing.T) {
116116
Tag: []string{"^refs/tags/(\\d+\\.)+\\d+$"},
117117
},
118118
Unless: Rules{
119-
Event: []string{"deployment", "pull_request:opened", "pull_request:synchronized", "comment:created", "comment:edited"},
119+
Event: []string{"deployment", "pull_request:opened", "pull_request:synchronize", "comment:created", "comment:edited"},
120120
Path: []string{"foo.txt", "/foo/bar.txt"},
121121
},
122122
Matcher: "regexp",

yaml/testdata/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ steps:
3131
image: openjdk:latest
3232
pull: true
3333
ruleset:
34-
event: [ push, pull_request:opened, pull_request:synchronized, pull_request:edited ]
34+
event: [ push, pull_request:opened, pull_request:synchronize, pull_request:edited ]
3535
volumes: [ /foo:/bar:ro ]
3636
ulimits: [ foo=1024:2048 ]
3737

0 commit comments

Comments
 (0)