Skip to content

Commit

Permalink
fix(release): ensure git commits containing pipe can be parsed reliab…
Browse files Browse the repository at this point in the history
…ly (nrwl#27840)
  • Loading branch information
JamesHenry authored Sep 10, 2024
1 parent 44da27d commit 0b81de2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/nx/src/command-line/release/utils/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]);

Expand All @@ -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,
Expand Down

0 comments on commit 0b81de2

Please sign in to comment.