From 4889634ea9ae8f5fc81a1ea6c63f85d0b7572fbd Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Thu, 13 Jun 2019 18:11:18 -0700 Subject: [PATCH] added action to when clause --- CHANGELOG.md | 1 + yaml/cond.go | 1 + yaml/pretty/pipeline.go | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbd6154..e3e5550 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added +- Added Action field to trigger and when clause, by [@bradrydzewski](https://github.com/bradrydzewski). ### Fixed diff --git a/yaml/cond.go b/yaml/cond.go index a26a021..f6716ed 100644 --- a/yaml/cond.go +++ b/yaml/cond.go @@ -18,6 +18,7 @@ import filepath "github.com/bmatcuk/doublestar" // Conditions defines a group of conditions. type Conditions struct { + Action Condition `json:"action,omitempty"` Cron Condition `json:"cron,omitempty"` Ref Condition `json:"ref,omitempty"` Repo Condition `json:"repo,omitempty"` diff --git a/yaml/pretty/pipeline.go b/yaml/pretty/pipeline.go index dcd97fa..e6cafdb 100644 --- a/yaml/pretty/pipeline.go +++ b/yaml/pretty/pipeline.go @@ -122,6 +122,9 @@ func printConcurrency(w writer, v yaml.Concurrency) { func printConditions(w writer, name string, v yaml.Conditions) { w.WriteTag(name) w.IndentIncrease() + if !isConditionEmpty(v.Action) { + printCondition(w, "action", v.Action) + } if !isConditionEmpty(v.Branch) { printCondition(w, "branch", v.Branch) } @@ -276,7 +279,9 @@ func isConcurrencyEmpty(v yaml.Concurrency) bool { // helper function returns true if the conditions // object is empty. func isConditionsEmpty(v yaml.Conditions) bool { - return isConditionEmpty(v.Branch) && + return isConditionEmpty(v.Action) && + isConditionEmpty(v.Branch) && + isConditionEmpty(v.Cron) && isConditionEmpty(v.Event) && isConditionEmpty(v.Instance) && isConditionEmpty(v.Paths) &&