diff --git a/scripts/generate-changelog.js b/scripts/generate-changelog.js index de0bc47b..12e771ab 100644 --- a/scripts/generate-changelog.js +++ b/scripts/generate-changelog.js @@ -18,7 +18,17 @@ function generateChangelog(onlyPackages) { const changed = findChangedFilesSince(`${commit.hash}~1`, commit.hash) - const line = `- ${commit.hash}: ${breaking ? '**❗ BREAKING** ' : ''}${commit.msg}` + let line = `- ${commit.hash}: ${breaking ? '**❗ BREAKING** ' : ''}${commit.msg}` + + if (breaking && commit.description) { + line += + '\n' + + commit.description + .trim() + .split('\n') + .map((line) => ` ${line}`) + .join('\n') + } for (const file of changed) { if (!file.startsWith('packages/')) continue diff --git a/scripts/git-utils.js b/scripts/git-utils.js index 43123fbf..a82b8115 100644 --- a/scripts/git-utils.js +++ b/scripts/git-utils.js @@ -20,16 +20,33 @@ function findChangedFilesSince(tag, until = 'HEAD') { } function getCommitsSince(tag, until = 'HEAD') { - return cp - .execSync(`git log --pretty="format:%H %s" ${tag}..${until}`, { encoding: 'utf8', stdio: 'pipe' }) + const delim = `---${Math.random().toString(36).slice(2)}---` + + const lines = cp + .execSync(`git log --pretty="format:%H %s%n%b%n${delim}" ${tag}..${until}`, { encoding: 'utf8', stdio: 'pipe' }) .trim() .split('\n') - .reverse() - .map((it) => { - const [hash, ...msg] = it.split(' ') - return { hash, msg: msg.join(' ') } - }) + const items = [] + + let current = null + + for (const line of lines) { + if (line === delim) { + if (current) items.push(current) + current = null + } else if (current) { + if (current.description) current.description += '\n' + current.description += line + } else { + const [hash, ...msg] = line.split(' ') + current = { hash, msg: msg.join(' '), description: '' } + } + } + + if (current) items.push(current) + + return items.reverse() } function parseConventionalCommit(msg) {