Skip to content

Commit

Permalink
Fix calculation of commits for flow diff
Browse files Browse the repository at this point in the history
  • Loading branch information
nvuillam committed Dec 22, 2024
1 parent 9157c4f commit 19eaa8e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/common/utils/gitUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,18 @@ 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(
prInfo?.sourceBranch || currentGitBranch,
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();
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 19eaa8e

Please sign in to comment.