Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(release): make commits separator in git log command more unique #29261

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions packages/nx/src/command-line/release/utils/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,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 = '§§§';
// Use unique enough separators that we can be relatively certain will not occur within the commit message itself
const commitMetadataSeparator = '§§§';
const commitsSeparator = '|@-------@|';
// https://git-scm.com/docs/pretty-formats
const args = [
'--no-pager',
'log',
range,
`--pretty="----%n%s${separator}%h${separator}%an${separator}%ae%n%b"`,
`--pretty="${commitsSeparator}%n%s${commitMetadataSeparator}%h${commitMetadataSeparator}%an${commitMetadataSeparator}%ae%n%b"`,
'--name-status',
];
// Support cases where the nx workspace root is located at a nested path within the git repo
Expand All @@ -142,12 +143,13 @@ export async function getGitDiff(
const r = await execCommand('git', args);

return r
.split('----\n')
.split(`${commitsSeparator}\n`)
.splice(1)
.map((line) => {
const [firstLine, ..._body] = line.split('\n');
const [message, shortHash, authorName, authorEmail] =
firstLine.split(separator);
const [message, shortHash, authorName, authorEmail] = firstLine.split(
commitMetadataSeparator
);
const r: RawGitCommit = {
message,
shortHash,
Expand Down
Loading