From 1abe4c4314a918ca3d50a2266a53b7e668bdce00 Mon Sep 17 00:00:00 2001 From: Nicolas Vuillamy Date: Thu, 3 Oct 2024 22:45:52 +0200 Subject: [PATCH] hardis:project:deploy:smart : Fix parsing of error strings --- CHANGELOG.md | 2 ++ src/common/utils/deployTips.ts | 16 +++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b120a0870..e779dd9d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ Note: Can be used with `sfdx plugins:install sfdx-hardis@beta` and docker image `hardisgroupcom/sfdx-hardis@beta` +- hardis:project:deploy:smart : Fix parsing of error strings + ## [5.0.9] 2024-10-03 - Fix link to tip doc from Pull Request / Merge Request comments diff --git a/src/common/utils/deployTips.ts b/src/common/utils/deployTips.ts index bd32e148a..63086611a 100644 --- a/src/common/utils/deployTips.ts +++ b/src/common/utils/deployTips.ts @@ -34,10 +34,8 @@ export async function analyzeDeployErrorLogs(log: string, includeInLog = true, o index++; continue; } - if ((logLine.trim().startsWith("Error") || logLine.trim().startsWith("| Error")) && - !(updatedLogLines[index + 1] && - (!updatedLogLines[index + 1].trim().startsWith("Error") || !updatedLogLines[index + 1].trim().startsWith("| Error")) - )) { + if (isErrorLine(logLine) && updatedLogLines[index + 1] && isErrorLine(updatedLogLines[index + 1]) + ) { const aiTip = await findAiTip(logLine.trim()); // Complete with AI if possible if (aiTip && aiTip.success) { @@ -80,6 +78,14 @@ export async function analyzeDeployErrorLogs(log: string, includeInLog = true, o return { tips, errorsAndTips, failedTests, errLog: logResLines.join("\n") }; } +function isErrorLine(str: string) { + const strTrim = str.trim(); + if (strTrim.startsWith("Error") || strTrim.startsWith("| Error")) { + return true; + } + return false; +} + function extractFailedTestsInfoForSfdxCommand(logRaw: string, failedTests: any[]) { const regexFailedTests = /Test Failures([\S\s]*?)Test Success/gm; if (logRaw.match(regexFailedTests)) { @@ -250,7 +256,7 @@ async function matchesTip(tipDefinition: any, includeInLog = true): Promise str.startsWith("Error") || str.startsWith(" Error") || str.startsWith("| Error") || str.startsWith(firstYellowChar)); + return strIn.split(/\r?\n/).filter((str) => isErrorLine(str) || str.startsWith(firstYellowChar)); } // This data will be caught later to build a pull request message