浏览代码

fix(changelog): allow breaking change message to span multiple lines

This also allows the option to put extra paragraphs after the BREAKING CHANGE
message while properly displaying the breaking change message. Useful, for
example, to add signed-off or co-authored lines.
Marc Cornellà 4 年之前
父节点
当前提交
e2c73cf59a
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      tools/changelog.sh

+ 6 - 2
tools/changelog.sh

@@ -86,11 +86,15 @@ function parse-commit {
 
   # Return subject if the body or subject match the breaking change format
   function commit:is-breaking {
-    local subject="$1" body="$2"
+    local subject="$1" body="$2" message
 
     if [[ "$body" =~ "BREAKING CHANGE: (.*)" || \
       "$subject" =~ '^[^ :\)]+\)?!: (.*)$' ]]; then
-      echo "${match[1]}"
+      message="${match[1]}"
+      # skip next paragraphs (separated by two newlines or more)
+      message="${message%%$'\n\n'*}"
+      # ... and replace newlines with spaces
+      echo "${message//$'\n'/ }"
     else
       return 1
     fi