Created
January 5, 2019 11:49
-
-
Save chengjianhua/a7ea079c67447c73aa8b96f62b78e773 to your computer and use it in GitHub Desktop.
format-git-commit-message
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const rawMessage = `Merge branch 'fix/bundle' into 'develop' | |
asdasdasdasdasd | |
fix(bundle): fix bug in bundle_edit | |
See merge request frontend/darwin-yy!63`; | |
const firstLineBreakIndex = rawMessage.indexOf('\n'); | |
let computedMessage; | |
if (firstLineBreakIndex + 1 >= rawMessage.length) { | |
computedMessage = rawMessage; | |
} else { | |
const nextToFirstLineBreak = rawMessage[firstLineBreakIndex + 1]; | |
if (nextToFirstLineBreak !== '\n') { | |
computedMessage = | |
rawMessage.substring(0, firstLineBreakIndex) + | |
' ' + | |
rawMessage | |
.substring(firstLineBreakIndex + 1, rawMessage.length) | |
.trimLeft(); | |
} else { | |
return rawMessage; | |
} | |
} | |
return computedMessage; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment