Skip to content

Commit b234d2d

Browse files
authored
fix: rules regex (!~)[does not match operator] returning wrong result (#1633)
1 parent 2494389 commit b234d2d

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/utils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,8 @@ export class Utils {
294294
return `.matchRE2JS(${_rhs}) ${_operator} null`;
295295
});
296296

297-
// Convert all null.match functions to false
298297
evalStr = evalStr.replace(/null.matchRE2JS\(.+?\)\s*!=\s*null/g, "false");
299-
evalStr = evalStr.replace(/null.matchRE2JS\(.+?\)\s*==\s*null/g, "false");
298+
evalStr = evalStr.replace(/null.matchRE2JS\(.+?\)\s*==\s*null/g, "true");
300299

301300
evalStr = evalStr.trim();
302301

tests/rules.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ test("Negated regex on undef var", () => {
3838
];
3939
const variables = {};
4040
const rulesResult = Utils.getRulesResult({argv, cwd: "", rules, variables}, gitData);
41-
expect(rulesResult).toEqual({when: "never", allowFailure: false, variables: undefined});
41+
expect(rulesResult).toEqual({when: "on_success", allowFailure: false, variables: undefined});
4242
});
4343

4444
test("GITLAB_CI fail and fallback", () => {

0 commit comments

Comments
 (0)