From 7c5c91d542d9c5f1637b0a96a5ac66777e8d6c8d Mon Sep 17 00:00:00 2001 From: ANGkeith Date: Thu, 30 Jan 2025 19:02:14 +0800 Subject: [PATCH] fix: "" in rules:exists should not be treated as truthy (#1485) --- src/utils.ts | 3 +++ tests/test-cases/rules-exists/.gitlab-ci.yml | 7 +++++++ tests/test-cases/rules-exists/integration.test.ts | 1 + 3 files changed, 11 insertions(+) diff --git a/src/utils.ts b/src/utils.ts index 6f245609e..6e38d28b8 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -285,6 +285,9 @@ ${evalStr} static evaluateRuleExist (cwd: string, ruleExists: string[] | undefined): boolean { if (ruleExists === undefined) return true; for (const pattern of ruleExists) { + if (pattern == "") { + continue; + } if (globby.sync(pattern, {dot: true, cwd}).length > 0) { return true; } diff --git a/tests/test-cases/rules-exists/.gitlab-ci.yml b/tests/test-cases/rules-exists/.gitlab-ci.yml index 7f80d46bd..f9b87498c 100644 --- a/tests/test-cases/rules-exists/.gitlab-ci.yml +++ b/tests/test-cases/rules-exists/.gitlab-ci.yml @@ -56,3 +56,10 @@ var-expand-test: rules: - exists: - ${DIR}/recursive.file + +rule-exist-empty-string: + script: + - echo "$CI_JOB_NAME Executed!" + rules: + - exists: + - "" diff --git a/tests/test-cases/rules-exists/integration.test.ts b/tests/test-cases/rules-exists/integration.test.ts index efeef9586..75c5c46b4 100644 --- a/tests/test-cases/rules-exists/integration.test.ts +++ b/tests/test-cases/rules-exists/integration.test.ts @@ -21,4 +21,5 @@ test("rules-exists", async () => { expect(output).not.toContain("File Skipped!"); expect(output).not.toContain("Directory Skipped!"); expect(output).not.toContain("Directory Recursive Skipped!"); + expect(output).not.toContain("rule-exist-empty-string Executed!"); });