mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-15 18:57:01 +00:00
parent
965f86d04e
commit
c64bbd5c93
3 changed files with 25 additions and 0 deletions
|
@ -231,11 +231,14 @@ func (rc *RunContext) isEnabled(ctx context.Context) bool {
|
|||
// EvalBool evaluates an expression against current run context
|
||||
func (rc *RunContext) EvalBool(expr string) bool {
|
||||
if expr != "" {
|
||||
//v, err := rc.ExprEval.Evaluate(fmt.Sprintf("if (%s) { true } else { false }", expr))
|
||||
expr := fmt.Sprintf("Boolean(%s)", expr)
|
||||
v, err := rc.ExprEval.Evaluate(expr)
|
||||
if err != nil {
|
||||
log.Errorf("Error evaluating expression '%s' - %v", expr, err)
|
||||
return false
|
||||
}
|
||||
log.Debugf("expression '%s' evaluated to '%s'", expr, v)
|
||||
return v == "true"
|
||||
}
|
||||
return true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue