提交记录修改release.sh+20 −2看文件
修改tests/release.sh+20 −0看文件
| @@ -85,7 +85,10 @@ valid_version() { | ||
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | # The "## X.Y.Z" section of CHANGELOG.md, without its heading and without |
| 88 | 删除:# leading or trailing blank lines. Empty when there is none. | |
| 88 | 新增:# leading or trailing blank lines. Empty when there is none. The file is | |
| 89 | 新增:# wrapped for reading in a terminal, GitHub is not: a paragraph or list item | |
| 90 | 新增:# continued on the next lines is joined into one line. Code fences, headings, | |
| 91 | 新增:# tables and quotes are left as written. | |
| 89 | 92 | changelog_notes() { |
| 90 | 93 | awk -v v="$1" ' |
| 91 | 94 | /^## / { if (inside) exit; inside = ($2 == v); next } |
| @@ -93,7 +96,22 @@ changelog_notes() { | ||
| 93 | 96 | END { |
| 94 | 97 | first = 1; while (first <= n && lines[first] ~ /^[ \t]*$/) first++ |
| 95 | 98 | last = n; while (last >= first && lines[last] ~ /^[ \t]*$/) last-- |
| 96 | 删除: for (i = first; i <= last; i++) print lines[i] | |
| 99 | 新增: for (i = first; i <= last; i++) { | |
| 100 | 新增: l = lines[i] | |
| 101 | 新增: if (fence) { print l; if (l ~ /^[ \t]*(```|~~~)/) fence = 0; continue } | |
| 102 | 新增: if (l ~ /^[ \t]*(```|~~~)/ || l ~ /^[ \t]*$/) { | |
| 103 | 新增: if (joinable) printf "\n" | |
| 104 | 新增: print l; joinable = 0; fence = (l ~ /[`~]/); continue | |
| 105 | 新增: } | |
| 106 | 新增: if (joinable && l !~ /^[ \t]*([-*+]|[0-9]+[.)])[ \t]/ && l !~ /^[ \t]*[#|>]/) { | |
| 107 | 新增: sub(/^[ \t]+/, "", l); printf " %s", l; continue | |
| 108 | 新增: } | |
| 109 | 新增: if (joinable) printf "\n" | |
| 110 | 新增: printf "%s", l | |
| 111 | 新增: joinable = (l !~ /^[ \t]*[#|>]/) | |
| 112 | 新增: if (!joinable) printf "\n" | |
| 113 | 新增: } | |
| 114 | 新增: if (joinable) printf "\n" | |
| 97 | 115 | } |
| 98 | 116 | ' "$REPO_DIR/CHANGELOG.md" |
| 99 | 117 | } |
| @@ -44,6 +44,26 @@ check "notes: only that version's section" "$("$SB/notes/release.sh" notes 2.0.0 | ||
| 44 | 44 | check "notes: the last section too" "$("$SB/notes/release.sh" notes 1.0.0)" "- one" |
| 45 | 45 | "$SB/notes/release.sh" notes 3.0.0 >/dev/null 2>&1 |
| 46 | 46 | check "notes: an absent version fails" "$?" "1" |
| 47 | 新增:# Wrapped for the terminal, joined for GitHub: items and paragraphs become one | |
| 48 | 新增:# line each, headings, fences, tables and sub-items stay as written. | |
| 49 | 新增:printf '# Changelog\n\n## 4.0.0\n\nIntro line one\ncontinued here.\n\n### Added\n\n- first item\n continued\n and again\n- second item\n - sub item\n wrapped\n\n```\nkept\n as is\n```\n\n| a | b |\n|---|---|\n| 1 | 2 |\n\n## 3.0.0\n\n- old\n' > "$SB/notes/CHANGELOG.md" | |
| 50 | 新增:want='Intro line one continued here. | |
| 51 | 新增: | |
| 52 | 新增:### Added | |
| 53 | 新增: | |
| 54 | 新增:- first item continued and again | |
| 55 | 新增:- second item | |
| 56 | 新增: - sub item wrapped | |
| 57 | 新增: | |
| 58 | 新增:``` | |
| 59 | 新增:kept | |
| 60 | 新增: as is | |
| 61 | 新增:``` | |
| 62 | 新增: | |
| 63 | 新增:| a | b | | |
| 64 | 新增:|---|---| | |
| 65 | 新增:| 1 | 2 |' | |
| 66 | 新增:check "notes: wrapped lines are joined, the rest is kept" "$("$SB/notes/release.sh" notes 4.0.0)" "$want" | |
| 47 | 67 | "$SELF_DIR/release.sh" 1.2 >/dev/null 2>&1 |
| 48 | 68 | check "a malformed version is refused before anything else" "$?" "1" |
| 49 | 69 | "$SELF_DIR/release.sh" >/dev/null 2>&1 |

