From 0c47b08e69fc104ad2ae90150389148273d9cb07 Mon Sep 17 00:00:00 2001 From: bado Date: Tue, 5 Nov 2024 12:29:02 +0800 Subject: [PATCH] ci(check-ci-skip): fix commitMessagesMetadata.forEach is not a function Primary Changes ---------------- 1. Added condition to commitMessagesMetadata to check if commit message is array or not. Fixes #3614 Signed-off-by: bado --- tools/ci-skip-for-maintainers.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tools/ci-skip-for-maintainers.js b/tools/ci-skip-for-maintainers.js index 911c637ca4..2504ef88c1 100644 --- a/tools/ci-skip-for-maintainers.js +++ b/tools/ci-skip-for-maintainers.js @@ -15,13 +15,13 @@ const MAINTAINERS_REGEX = new RegExp( const main = async () => { const markdownContent = readFileSync(MaintainersFile, "utf-8"); - const args = process.argv.slice(2); - const pullReqUrl = args[0]; - const committerLogin = args[1]; + //const args = process.argv.slice(2); + //const pullReqUrl = args[0]; + //const committerLogin = args[1]; //Uncomment these lines and change it for local machine testing purposes: - //const pullReqUrl = "https://api.github.com/repos//cactus/pulls/"; - //const committerLogin = ""; + const pullReqUrl = "https://api.github.com/repos/zondervancalvez/cactus/pulls/7"; + const committerLogin = "zondervancalvez"; const fetchJsonFromUrl = async (url) => { const fetchResponse = await fetch(url); @@ -33,10 +33,14 @@ const main = async () => { pullReqUrl + "/commits", ); - commitMessagesMetadata.forEach((commitMessageMetadata) => { - // get commit message body - commitMessageList.push(commitMessageMetadata["commit"]["message"]); - }); + if (Array.isArray(commitMessagesMetadata)) { + commitMessagesMetadata.forEach((commitMessageMetadata) => { + // get commit message body + commitMessageList.push(commitMessageMetadata["commit"]["message"]); + }); + } else { + console.error("Commit message data is empty or null"); + } // Check if skip-ci is found in commit message const checkSkipCI = () => {