vim-patch.sh: perf, readability #9044

closes #9044
This commit is contained in:
Daniel Hahler
2019-04-12 00:26:52 +02:00
committed by Justin M. Keyes
parent ae88e46563
commit 49ca20aaf3

View File

@@ -357,13 +357,12 @@ list_vim_commits() { (
} }
# Gets all Vim commits since the "start" commit. # Gets all Vim commits since the "start" commit.
list_vim_commits() { ( list_vim_commits() { (
cd "${VIM_SOURCE_DIR}" && git log --reverse --format='%H' v8.0.0000..HEAD cd "${VIM_SOURCE_DIR}" && git log --reverse --format='%H' v8.0.0000..HEAD
) } ) }
# Prints all (sorted) "vim-patch:xxx" tokens found in the Nvim git log.
local tokens # Prints all (sorted) "vim-patch:xxx" tokens found in the Nvim git log.
list_vimpatch_tokens() {
# Use sed…{7,7} to normalize (internal) Git hashes (for tokens caches). # Use sed…{7,7} to normalize (internal) Git hashes (for tokens caches).
git -C "${NVIM_SOURCE_DIR}" log -E --grep='vim-patch:[^ ,{]{7,}' \ git -C "${NVIM_SOURCE_DIR}" log -E --grep='vim-patch:[^ ,{]{7,}' \
| grep -oE 'vim-patch:[^ ,{:]{7,}' \ | grep -oE 'vim-patch:[^ ,{:]{7,}' \
@@ -377,29 +376,31 @@ list_vimpatch_numbers() {
list_vimpatch_numbers() { list_vimpatch_numbers() {
# Transform "vim-patch:X.Y.ZZZZ" to "ZZZZ". # Transform "vim-patch:X.Y.ZZZZ" to "ZZZZ".
list_vimpatch_tokens | while read vimpatch_token; do list_vimpatch_tokens | while read vimpatch_token; do
echo "$vimpatch_token" | grep '8\.0\.' | sed 's/.*vim-patch:8\.0\.\([0-9a-z]\+\).*/\1/' echo "$vimpatch_token" | grep '8\.0\.' | sed 's/.*vim-patch:8\.0\.\([0-9a-z]\+\).*/\1/'
done
} }
# Prints a newline-delimited list of Vim commits, for use by scripts.
list_missing_vimpatches() {
local token vim_commit vim_tag patch_number
declare -A tokens declare -A tokens
local tokens vim_commit vim_commits is_missing vim_tag patch_number # Find all "vim-patch:xxx" tokens in the Nvim git log.
for token in $(list_vimpatch_tokens); do for token in $(list_vimpatch_tokens); do
tokens="$(list_vimpatch_tokens)" tokens[$token]=1
done
# Get missing Vim commits
vim_commits="$(list_vim_commits)"
for vim_commit in ${vim_commits}; do
# Check for vim-patch:<commit_hash> (usually runtime updates).
is_missing="$(echo "$tokens" | >/dev/null 2>&1 grep "vim\-patch:${vim_commit:0:7}" && echo false || echo true)"
if ! [ "$is_missing" = "false" ] \
&& vim_tag="$(cd "${VIM_SOURCE_DIR}" && git describe --tags --exact-match "${vim_commit}" 2>/dev/null)"
# Get missing Vim commits # Get missing Vim commits
for vim_commit in $(list_vim_commits); do for vim_commit in $(list_vim_commits); do
# Check for vim-patch:<tag> (not commit hash). # Check for vim-patch:<commit_hash> (usually runtime updates).
patch_number="${vim_tag:1}" # "v7.4.0001" => "7.4.0001" token="vim-patch:${vim_commit:0:7}"
if [[ "${tokens[$token]-}" ]]; then
continue
fi
if vim_tag="$(git -C "${VIM_SOURCE_DIR}" describe --tags --exact-match "${vim_commit}" 2>/dev/null)"; then
# Check for vim-patch:<tag> (not commit hash).
patch_number="vim-patch:${vim_tag:1}" # "v7.4.0001" => "7.4.0001"
if [[ "${tokens[$patch_number]-}" ]]; then if [[ "${tokens[$patch_number]-}" ]]; then
continue continue
fi fi
@@ -410,7 +411,7 @@ show_vimpatches() {
done done
} }
# Prints a human-formatted list of Vim commits, with instructional messages. # Prints a human-formatted list of Vim commits, with instructional messages.
show_vimpatches() { show_vimpatches() {
get_vim_sources get_vim_sources
printf "\nVim patches missing from Neovim:\n" printf "\nVim patches missing from Neovim:\n"