Skip to content

Improved handling of multiline commits.#15

Merged
richardgaunt merged 1 commit into
mainfrom
feature/handle-multiline-commits
Dec 6, 2025
Merged

Improved handling of multiline commits.#15
richardgaunt merged 1 commit into
mainfrom
feature/handle-multiline-commits

Conversation

@richardgaunt
Copy link
Copy Markdown
Owner

@richardgaunt richardgaunt commented Dec 6, 2025

Checklist before requesting a review

  • This PR does not have an associated ticket
  • I have provided information in section about WHY something was done if this was not a normal implementation
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • I have run new and existing relevant tests locally with my changes, and they passed
  • I have provided screenshots, where applicable

Changed

  1. Fixed multiline commits.

Screenshots

Summary by CodeRabbit

  • Bug Fixes
    • Improved commit parsing for PR descriptions: commits are now reliably separated and empty entries ignored.
    • PR descriptions no longer include commit bodies or multi-line message content; only commit hashes and subject lines are shown.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 6, 2025

Walkthrough

getRecentCommits in index.js now uses a null-byte (%x00) git-log separator, filters empty entries, and returns only commit hash and subject; commit body extraction and display were removed.

Changes

Cohort / File(s) Summary
Git commit parsing refactor
index.js
Replaced literal delimiter with %x00 null-byte separator for git log output; split output on null bytes and filtered empty lines; removed parsing and exposure of commit body, returning only hash and subject.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Confirm the git log format string correctly emits null bytes and is portable across environments.
  • Verify empty-line filtering doesn't drop valid entries.
  • Test behavior with commits that include multi-line messages, special characters, or trailing nulls to ensure no data corruption.
  • Check downstream consumers for assumptions about commit.body and update if needed.

Poem

🐰 I nibble bytes both small and null,
I hop through logs so tidy and full,
Bodies trimmed, the hashes hum,
Subjects dance — the changelog's done. ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Improved handling of multiline commits' accurately reflects the main change: the PR modifies how multiline commits are processed by using a null-byte separator and filtering the output to only hash and subject.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/handle-multiline-commits

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7fa9e12 and 5c4712a.

📒 Files selected for processing (1)
  • index.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • index.js

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 6, 2025

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 8.66%. Comparing base (172e38d) to head (5c4712a).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
index.js 0.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            main     #15      +/-   ##
========================================
+ Coverage   8.52%   8.66%   +0.13%     
========================================
  Files          1       1              
  Lines        129     127       -2     
========================================
  Hits          11      11              
+ Misses       118     116       -2     
Flag Coverage Δ
unittests 8.66% <0.00%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
index.js (1)

242-244: Remove dead code.

The commit.body field is no longer returned by getRecentCommits() (line 29), so this code block will never execute.

Apply this diff to remove the dead code:

   for (const commit of commits) {
     console.log(`\n${commit.hash} ${commit.subject}`);
-    if (commit.body) {
-      console.log(`${commit.body}`);
-    }
 
     const includeCommit = await confirm({
       message: '🔄 Include this commit in PR description?'
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 172e38d and 7fa9e12.

📒 Files selected for processing (1)
  • index.js (1 hunks)
🔇 Additional comments (1)
index.js (1)

27-30: LGTM: Simplified return structure.

Removing the body field simplifies the commit data structure and aligns with the PR objective to fix multiline commit handling.

Comment thread index.js
Comment on lines +21 to +26
// Use %x00 (null byte) as commit separator to handle multi-line messages
const format = '--pretty=format:%h\\|\\|\\|%s%x00';
const output = execSync(`git log -${count} ${format}`).toString().trim();

return output.split('\n').map(line => {
const [hash, subject, body] = line.split('|||');
return output.split('\x00').filter(Boolean).map(line => {
const [hash, subject] = line.split('|||');
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Good approach with null byte separator, but consider edge case.

The use of %x00 (null byte) as a separator is a robust solution for handling multi-line commit messages. However, the ||| delimiter could theoretically appear in commit subjects, causing incorrect parsing.

Consider using a more unique delimiter or using different format specifiers. For example:

-    // Use %x00 (null byte) as commit separator to handle multi-line messages
-    const format = '--pretty=format:%h\\|\\|\\|%s%x00';
+    // Use %x00 (null byte) as both field and commit separator to handle multi-line messages
+    const format = '--pretty=format:%h%x00%s%x00%x00';
     const output = execSync(`git log -${count} ${format}`).toString().trim();
 
-    return output.split('\x00').filter(Boolean).map(line => {
-      const [hash, subject] = line.split('|||');
+    return output.split('\x00\x00').filter(Boolean).map(line => {
+      const [hash, subject] = line.split('\x00');
       return {
         hash,
         subject
       };
     });

Testing no multiline commit messages.
@richardgaunt richardgaunt force-pushed the feature/handle-multiline-commits branch from 7fa9e12 to 5c4712a Compare December 6, 2025 02:40
@richardgaunt richardgaunt merged commit be0d0ae into main Dec 6, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant