summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2021-09-10 20:10:26 -0600
committerTuowen Zhao <ztuowen@gmail.com>2021-09-10 20:10:26 -0600
commit3c73976ef306d68a85d60c94be9a1dcdc33fa2bf (patch)
tree619ba4b5874b92ada9dc089c67a435dd3149748a /tools
parentf8b7b6584bf1ca7e836ba9cc13fcce573047fb07 (diff)
parent735808f48d54aabce540f6c90294e21118104cf4 (diff)
downloadzsh-3c73976ef306d68a85d60c94be9a1dcdc33fa2bf.tar.gz
zsh-3c73976ef306d68a85d60c94be9a1dcdc33fa2bf.tar.bz2
zsh-3c73976ef306d68a85d60c94be9a1dcdc33fa2bf.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'tools')
-rwxr-xr-xtools/changelog.sh29
-rwxr-xr-xtools/upgrade.sh2
2 files changed, 19 insertions, 12 deletions
diff --git a/tools/changelog.sh b/tools/changelog.sh
index 6913ae49a..7329a9526 100755
--- a/tools/changelog.sh
+++ b/tools/changelog.sh
@@ -181,6 +181,12 @@ function display-release {
return
fi
+ # Get length of longest scope for padding
+ local max_scope=0
+ for hash in ${(k)scopes}; do
+ max_scope=$(( max_scope < ${#scopes[$hash]} ? ${#scopes[$hash]} : max_scope ))
+ done
+
##* Formatting functions
# Format the hash according to output format
@@ -220,18 +226,13 @@ function display-release {
#* Uses $scopes (A) and $hash from outer scope
local scope="${1:-${scopes[$hash]}}"
- # Get length of longest scope for padding
- local max_scope=0 padding=0
- for hash in ${(k)scopes}; do
- max_scope=$(( max_scope < ${#scopes[$hash]} ? ${#scopes[$hash]} : max_scope ))
- done
-
# If no scopes, exit the function
if [[ $max_scope -eq 0 ]]; then
return
fi
# Get how much padding is required for this scope
+ local padding=0
padding=$(( max_scope < ${#scope} ? 0 : max_scope - ${#scope} ))
padding="${(r:$padding:: :):-}"
@@ -285,15 +286,21 @@ function display-release {
(( $#breaking != 0 )) || return 0
case "$output" in
+ text) fmt:header "\e[31mBREAKING CHANGES" 3 ;;
raw) fmt:header "BREAKING CHANGES" 3 ;;
- text|md) fmt:header "⚠ BREAKING CHANGES" 3 ;;
+ md) fmt:header "BREAKING CHANGES ⚠" 3 ;;
esac
- local hash subject
+ local hash message
+ local wrap_width=$(( (COLUMNS < 100 ? COLUMNS : 100) - 3 ))
for hash message in ${(kv)breaking}; do
- echo " - $(fmt:hash) $(fmt:scope)$(fmt:subject "${message}")"
- done | sort
- echo
+ # Format the BREAKING CHANGE message by word-wrapping it at maximum 100
+ # characters (use $COLUMNS if smaller than 100)
+ message="$(fmt -w $wrap_width <<< "$message")"
+ # Display hash and scope in their own line, and then the full message with
+ # blank lines as separators and a 3-space left padding
+ echo " - $(fmt:hash) $(fmt:scope)\n\n$(fmt:subject "$message" | sed 's/^/ /')\n"
+ done
}
function display:type {
diff --git a/tools/upgrade.sh b/tools/upgrade.sh
index 38fac3ce0..e9f8bc0f9 100755
--- a/tools/upgrade.sh
+++ b/tools/upgrade.sh
@@ -30,7 +30,7 @@ if [ -t 1 ]; then
BOLD=$(printf '\033[1m')
DIM=$(printf '\033[2m')
UNDER=$(printf '\033[4m')
- RESET=$(printf '\033[m')
+ RESET=$(printf '\033[0m')
fi
# Update upstream remote to ohmyzsh org