Skip to content

fix(git-node): handle multi-line trailers#1062

Open
aduh95 wants to merge 2 commits intonodejs:mainfrom
aduh95:multi-line-trailers
Open

fix(git-node): handle multi-line trailers#1062
aduh95 wants to merge 2 commits intonodejs:mainfrom
aduh95:multi-line-trailers

Conversation

@aduh95
Copy link
Copy Markdown
Contributor

@aduh95 aduh95 commented Apr 15, 2026

The current code assumes trailers will always be single-line, having a multi-line trailer currently results in non-sense output. This PR switch to relying on calling git interpret-trailers multiple times to filter out the trailers consistently.

Refs: nodejs/node#62577 (comment)

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.78%. Comparing base (f0587fa) to head (1e929e2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1062      +/-   ##
==========================================
+ Coverage   71.74%   71.78%   +0.03%     
==========================================
  Files          41       41              
  Lines        5878     5886       +8     
==========================================
+ Hits         4217     4225       +8     
  Misses       1661     1661              

☔ 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
Member

@Renegade334 Renegade334 left a comment

Choose a reason for hiding this comment

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

Just as a courtesy, I changed the "Fixes" in the PR description as GH was threatening to cross-close Matteo's announcement issue on the core repo.

Comment thread lib/landing_session.js
Comment on lines +332 to 340
const amended = original.trim().split('\n');
const stillInTrailers = () => {
const result = interpretTrailers(amended.join('\n'));
return result.length && originalTrailers.startsWith(result.trim());
};
for (let i = amended.length - 1; amended[i] === '' || stillInTrailers(); i--) {
// Remove last line until git no longer detects any trailers
amended.pop();
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Presumably we could skip this step if originalTrailers is empty?

Comment thread lib/landing_session.js
Comment on lines +332 to 340
const amended = original.trim().split('\n');
const stillInTrailers = () => {
const result = interpretTrailers(amended.join('\n'));
return result.length && originalTrailers.startsWith(result.trim());
};
for (let i = amended.length - 1; amended[i] === '' || stillInTrailers(); i--) {
// Remove last line until git no longer detects any trailers
amended.pop();
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if there's a better way than spawning a git process per line until the trailers are completely identified. Doesn't git interpret-trailers require a double-newline before a trailer block – could we look backwards for this instead?

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.

2 participants