From 19eaa8e1b444e9cf5e3782a81ef6c4d37352d7e1 Mon Sep 17 00:00:00 2001 From: Nicolas Vuillamy Date: Sun, 22 Dec 2024 11:09:13 +0100 Subject: [PATCH] Fix calculation of commits for flow diff --- src/common/utils/gitUtils.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/common/utils/gitUtils.ts b/src/common/utils/gitUtils.ts index ae74a1195..bd725815a 100644 --- a/src/common/utils/gitUtils.ts +++ b/src/common/utils/gitUtils.ts @@ -103,6 +103,7 @@ export async function computeCommitsSummary(checkOnly, pullRequestInfo: any) { uxLog(this, c.cyan('Computing commits summary...')); const currentGitBranch = await getCurrentGitBranch(); let logResults: (DefaultLogFields & ListLogLine)[] = []; + let previousTargetBranchCommit = ""; if (checkOnly || GitProvider.isDeployBeforeMerge()) { const prInfo = await GitProvider.getPullRequestInfo(); const deltaScope = await getGitDeltaScope( @@ -110,8 +111,10 @@ export async function computeCommitsSummary(checkOnly, pullRequestInfo: any) { prInfo?.targetBranch || process.env.FORCE_TARGET_BRANCH ); logResults = [...deltaScope.logResult.all]; + previousTargetBranchCommit = deltaScope.fromCommit; } else { const logRes = await git().log([`HEAD^..HEAD`]); + previousTargetBranchCommit = "HEAD^" logResults = [...logRes.all]; } logResults = arrayUniqueByKeys(logResults, ['message', 'body']).reverse(); @@ -189,7 +192,7 @@ export async function computeCommitsSummary(checkOnly, pullRequestInfo: any) { } } const flowListUnique = [...new Set(flowList)].sort(); - flowDiffMarkdown = await flowDiffToMarkdown(flowListUnique, logResults[0].hash, (logResults.at(-1) || { hash: "" }).hash); + flowDiffMarkdown = await flowDiffToMarkdown(flowListUnique, previousTargetBranchCommit, logResults[0].hash); } return {