Skip to content

Commit be0d0ae

Browse files
authored
Improved handling of multiline commits. (#15)
2 parents 172e38d + 5c4712a commit be0d0ae

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

index.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ const renderFileAsync = promisify(twig.renderFile);
1818
// Get the three most recent commits
1919
export function getRecentCommits(count = 3) {
2020
try {
21-
const format = '--pretty=format:%h\\|\\|\\|%s\\|\\|\\|%b';
21+
// Use %x00 (null byte) as commit separator to handle multi-line messages
22+
const format = '--pretty=format:%h\\|\\|\\|%s%x00';
2223
const output = execSync(`git log -${count} ${format}`).toString().trim();
2324

24-
return output.split('\n').map(line => {
25-
const [hash, subject, body] = line.split('|||');
25+
return output.split('\x00').filter(Boolean).map(line => {
26+
const [hash, subject] = line.split('|||');
2627
return {
2728
hash,
28-
subject,
29-
body: body ? body.trim() : ''
29+
subject
3030
};
3131
});
3232
} catch (error) {
@@ -239,9 +239,6 @@ export async function main() {
239239

240240
for (const commit of commits) {
241241
console.log(`\n${commit.hash} ${commit.subject}`);
242-
if (commit.body) {
243-
console.log(`${commit.body}`);
244-
}
245242

246243
const includeCommit = await confirm({
247244
message: '🔄 Include this commit in PR description?'

0 commit comments

Comments
 (0)