2019-03-13 21:47:47 +00:00
|
|
|
// Copyright 2019 Drone IO, Inc.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
2019-02-28 07:07:13 +00:00
|
|
|
|
2019-02-19 23:56:41 +00:00
|
|
|
package trigger
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/drone/drone-yaml/yaml"
|
|
|
|
"github.com/drone/drone/core"
|
|
|
|
)
|
|
|
|
|
|
|
|
func skipBranch(document *yaml.Pipeline, branch string) bool {
|
|
|
|
return !document.Trigger.Branch.Match(branch)
|
|
|
|
}
|
|
|
|
|
|
|
|
func skipRef(document *yaml.Pipeline, ref string) bool {
|
|
|
|
return !document.Trigger.Ref.Match(ref)
|
|
|
|
}
|
|
|
|
|
|
|
|
func skipEvent(document *yaml.Pipeline, event string) bool {
|
|
|
|
return !document.Trigger.Event.Match(event)
|
|
|
|
}
|
|
|
|
|
2019-07-30 03:37:04 +00:00
|
|
|
func skipAction(document *yaml.Pipeline, action string) bool {
|
|
|
|
return !document.Trigger.Action.Match(action)
|
|
|
|
}
|
|
|
|
|
2019-02-19 23:56:41 +00:00
|
|
|
func skipInstance(document *yaml.Pipeline, instance string) bool {
|
|
|
|
return !document.Trigger.Instance.Match(instance)
|
|
|
|
}
|
|
|
|
|
|
|
|
func skipTarget(document *yaml.Pipeline, env string) bool {
|
|
|
|
return !document.Trigger.Target.Match(env)
|
|
|
|
}
|
|
|
|
|
|
|
|
func skipRepo(document *yaml.Pipeline, repo string) bool {
|
|
|
|
return !document.Trigger.Repo.Match(repo)
|
|
|
|
}
|
|
|
|
|
2019-04-13 19:40:50 +00:00
|
|
|
func skipCron(document *yaml.Pipeline, cron string) bool {
|
|
|
|
return !document.Trigger.Cron.Match(cron)
|
|
|
|
}
|
|
|
|
|
2019-02-19 23:56:41 +00:00
|
|
|
func skipMessage(hook *core.Hook) bool {
|
|
|
|
switch {
|
|
|
|
case hook.Event == core.EventTag:
|
|
|
|
return false
|
|
|
|
case skipMessageEval(hook.Message):
|
|
|
|
return true
|
|
|
|
case skipMessageEval(hook.Title):
|
|
|
|
return true
|
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func skipMessageEval(str string) bool {
|
|
|
|
lower := strings.ToLower(str)
|
|
|
|
switch {
|
|
|
|
case strings.Contains(lower, "[ci skip]"),
|
|
|
|
strings.Contains(lower, "[skip ci]"),
|
|
|
|
strings.Contains(lower, "***no_ci***"):
|
|
|
|
return true
|
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// func skipPaths(document *config.Config, paths []string) bool {
|
|
|
|
// switch {
|
|
|
|
// // changed files are only returned for push and pull request
|
2019-04-16 03:05:41 +00:00
|
|
|
// // events. If the list of changed files is empty the system will
|
2019-02-19 23:56:41 +00:00
|
|
|
// // force-run all pipelines and pipeline steps
|
|
|
|
// case len(paths) == 0:
|
|
|
|
// return false
|
|
|
|
// // github returns a maximum of 300 changed files from the
|
|
|
|
// // api response. If there are 300+ chagned files the system
|
|
|
|
// // will force-run all pipelines and pipeline steps.
|
|
|
|
// case len(paths) >= 300:
|
|
|
|
// return false
|
|
|
|
// default:
|
|
|
|
// return !document.Trigger.Paths.MatchAny(paths)
|
|
|
|
// }
|
|
|
|
// }
|