Skip to main content

format_commit_message

Function format_commit_message 

Source
pub fn format_commit_message(prose: &str, ctx: &CommitContext<'_>) -> String
Expand description

Append the trailer block to the caller’s prose, separated by exactly one blank line. Normalises trailing newlines so "subject" and "subject\n" both produce "subject\n\nActor: …\n…".

When ctx.note carries a non-blank string, it is inserted between the prose and the trailer block — with exactly one blank line on each side. Whitespace-only notes are treated as absent (callers that want an empty note must pass None). The final layout is:

<prose>

<note, if present>

<trailer block>

Actor: is always emitted. Tool: is emitted when ctx.tool is set. Client: is emitted when ctx.client is set. Order: Tool, Actor, Client.

Public so both adapters share the same trailer block — the two paths must produce byte-identical commit messages for the same logical input.