From 5e27035f23c0af6b4c1309a6d7fb7680078ce441 Mon Sep 17 00:00:00 2001 From: JamesHenry Date: Tue, 10 Sep 2024 00:43:28 +0400 Subject: [PATCH] fix(release): ensure git commits containing pipe can be parsed reliably --- packages/nx/src/command-line/release/utils/git.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/nx/src/command-line/release/utils/git.ts b/packages/nx/src/command-line/release/utils/git.ts index c10a3692a63f8..1cddb27dc67ff 100644 --- a/packages/nx/src/command-line/release/utils/git.ts +++ b/packages/nx/src/command-line/release/utils/git.ts @@ -122,12 +122,15 @@ export async function getGitDiff( range = `${from}..${to}`; } + // Use a unique enough separator that we can be relatively certain will not occur within the commit message itself + const separator = 'ยงยงยง'; + // https://git-scm.com/docs/pretty-formats const r = await execCommand('git', [ '--no-pager', 'log', range, - '--pretty="----%n%s|%h|%an|%ae%n%b"', + `--pretty="----%n%s${separator}%h${separator}%an${separator}%ae%n%b"`, '--name-status', ]); @@ -137,7 +140,7 @@ export async function getGitDiff( .map((line) => { const [firstLine, ..._body] = line.split('\n'); const [message, shortHash, authorName, authorEmail] = - firstLine.split('|'); + firstLine.split(separator); const r: RawGitCommit = { message, shortHash,