( repository: Repository, context: ICommitContext )
| 16 | * See https://git-scm.com/docs/git-commit#_discussion |
| 17 | */ |
| 18 | export 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 | } |
no test coverage detected