Обновления 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

View File

@@ -48,14 +48,17 @@ function update_ohmyzsh() {
return
fi
# Remove lock directory on exit. `return 1` is important for when trapping a SIGINT:
# Remove lock directory on exit. `return $ret` is important for when trapping a SIGINT:
# The return status from the function is handled specially. If it is zero, the signal is
# assumed to have been handled, and execution continues normally. Otherwise, the shell
# will behave as interrupted except that the return status of the trap is retained.
# This means that for a CTRL+C, the trap needs to return the same exit status so that
# the shell actually exits what it's running.
trap "
unset -f current_epoch update_last_updated_file update_ohmyzsh
command rm -rf '$ZSH/log/update.lock'
return 1
ret=\$?
unset -f current_epoch update_last_updated_file update_ohmyzsh 2>/dev/null
command rm -rf '$ZSH/log/update.lock'
return \$ret
" EXIT INT QUIT
# Create or update .zsh-update file if missing or malformed

View File

@@ -1,16 +1,23 @@
#!/usr/bin/env zsh
# Protect against running with shells other than zsh
if [ -z "$ZSH_VERSION" ]; then
exec zsh "$0" "$@"
fi
# Protect against unwanted sourcing
case "$ZSH_EVAL_CONTEXT" in
*:file) echo "error: this file should not be sourced" && return ;;
esac
cd "$ZSH"
# Use colors, but only if connected to a terminal
# and that terminal supports them.
local -a RAINBOW
local RED GREEN YELLOW BLUE BOLD DIM UNDER RESET
setopt typeset_silent
typeset -a RAINBOW
typeset RED GREEN YELLOW BLUE BOLD DIM UNDER RESET
if [ -t 1 ]; then
RAINBOW=(
@@ -30,7 +37,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
@@ -72,7 +79,7 @@ if git pull --rebase --stat origin master; then
# Save the commit prior to updating
git config oh-my-zsh.lastVersion "$last_commit"
# Display changelog with less if available, otherwise just print it to the terminal
# Print changelog to the terminal
if [[ "$1" = --interactive ]]; then
"$ZSH/tools/changelog.sh" HEAD "$last_commit"
fi