Обновления 20.09.2021

This commit is contained in:
2021-09-20 09:41:06 +05:00
parent e7247fa93a
commit 997c07e49f
107 changed files with 2193 additions and 2126 deletions

View File

@@ -114,6 +114,11 @@ function parse-commit {
fi
}
# Ignore commit if it is a merge commit
if [[ $(command git show -s --format=%p $1 | wc -w) -gt 1 ]]; then
return
fi
# Parse commit with hash $1
local hash="$1" subject body warning rhash
subject="$(command git show -s --format=%s $hash)"
@@ -176,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
@@ -215,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:: :):-}"
@@ -280,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 {
@@ -386,9 +398,7 @@ function main {
# Get commit list from $until commit until $since commit, or until root
# commit if $since is unset, in short hash form.
# --first-parent is used when dealing with merges: it only prints the
# merge commit, not the commits of the merged branch.
command git rev-list --first-parent --abbrev-commit --abbrev=7 ${since:+$since..}$until | while read hash; do
command git rev-list --abbrev-commit --abbrev=7 ${since:+$since..}$until | while read hash; do
# Truncate list on versions with a lot of commits
if [[ -z "$since" ]] && (( ++read_commits > 35 )); then
truncate=1