Skip to content

Commit

Permalink
hardis:project:deploy:smart : Fix parsing of error strings
Browse files Browse the repository at this point in the history
  • Loading branch information
nvuillam committed Oct 3, 2024
1 parent 5b09abd commit 1abe4c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 11 additions & 5 deletions src/common/utils/deployTips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -250,7 +256,7 @@ async function matchesTip(tipDefinition: any, includeInLog = true): Promise<bool
}

function returnErrorLines(strIn) {
return strIn.split(/\r?\n/).filter((str) => 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
Expand Down

0 comments on commit 1abe4c4

Please sign in to comment.