79 lines
2 KiB
Go
79 lines
2 KiB
Go
|
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
||
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||
|
// that can be found in the LICENSE file.
|
||
|
|
||
|
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)
|
||
|
}
|
||
|
|
||
|
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)
|
||
|
}
|
||
|
|
||
|
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
|
||
|
// // events. If the list of changed files is empty the sytem will
|
||
|
// // 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)
|
||
|
// }
|
||
|
// }
|