Shorten or/and in expressions (#1939)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
0b4c67a4aa
commit
73d5f78294
|
@ -554,6 +554,10 @@ func (impl *interperterImpl) evaluateLogicalCompare(compareNode *actionlint.Logi
|
||||||
|
|
||||||
leftValue := reflect.ValueOf(left)
|
leftValue := reflect.ValueOf(left)
|
||||||
|
|
||||||
|
if IsTruthy(left) == (compareNode.Kind == actionlint.LogicalOpNodeKindOr) {
|
||||||
|
return impl.getSafeValue(leftValue), nil
|
||||||
|
}
|
||||||
|
|
||||||
right, err := impl.evaluateNode(compareNode.Right)
|
right, err := impl.evaluateNode(compareNode.Right)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -563,17 +567,8 @@ func (impl *interperterImpl) evaluateLogicalCompare(compareNode *actionlint.Logi
|
||||||
|
|
||||||
switch compareNode.Kind {
|
switch compareNode.Kind {
|
||||||
case actionlint.LogicalOpNodeKindAnd:
|
case actionlint.LogicalOpNodeKindAnd:
|
||||||
if IsTruthy(left) {
|
return impl.getSafeValue(rightValue), nil
|
||||||
return impl.getSafeValue(rightValue), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return impl.getSafeValue(leftValue), nil
|
|
||||||
|
|
||||||
case actionlint.LogicalOpNodeKindOr:
|
case actionlint.LogicalOpNodeKindOr:
|
||||||
if IsTruthy(left) {
|
|
||||||
return impl.getSafeValue(leftValue), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return impl.getSafeValue(rightValue), nil
|
return impl.getSafeValue(rightValue), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue