MCPcopy
hub / github.com/desktop/desktop / formatCommitMessage

Function formatCommitMessage

app/src/lib/format-commit-message.ts:18–36  ·  view source on GitHub ↗
(
  repository: Repository,
  context: ICommitContext
)

Source from the content-addressed store, hash-verified

16 * See https://git-scm.com/docs/git-commit#_discussion
17 */
18export async function formatCommitMessage(
19 repository: Repository,
20 context: ICommitContext
21) {
22 const { summary, description, trailers } = context
23
24 // Git always trim whitespace at the end of commit messages
25 // so we concatenate the summary with the description, ensuring
26 // that they're separated by two newlines. If we don't have a
27 // description or if it consists solely of whitespace that'll
28 // all get trimmed away and replaced with a single newline (since
29 // all commit messages needs to end with a newline for git
30 // interpret-trailers to work)
31 const message = `${summary}\n\n${description || ''}\n`.replace(/\s+$/, '\n')
32
33 return trailers !== undefined && trailers.length > 0
34 ? mergeTrailers(repository, message, trailers)
35 : message
36}

Calls 1

mergeTrailersFunction · 0.90

Tested by

no test coverage detected