scripts/vim-patch.sh: lazily update Vim source (#11207)

This gets done only initially, for `-l`, and when a commit cannot be found.

Also provide more compact instructions with `-l` / `show_vimpatches`.
This commit is contained in:
Daniel Hahler 2019-10-16 15:44:38 +02:00 committed by GitHub
parent 932edf4f33
commit c5c06665ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -89,7 +89,7 @@ get_vim_sources() {
echo "Cloning Vim into: ${VIM_SOURCE_DIR}" echo "Cloning Vim into: ${VIM_SOURCE_DIR}"
git clone https://github.com/vim/vim.git "${VIM_SOURCE_DIR}" git clone https://github.com/vim/vim.git "${VIM_SOURCE_DIR}"
cd "${VIM_SOURCE_DIR}" cd "${VIM_SOURCE_DIR}"
else elif [[ "${1-}" == update ]]; then
cd "${VIM_SOURCE_DIR}" cd "${VIM_SOURCE_DIR}"
if ! [ -d ".git" ] \ if ! [ -d ".git" ] \
&& ! [ "$(git rev-parse --show-toplevel)" = "${VIM_SOURCE_DIR}" ]; then && ! [ "$(git rev-parse --show-toplevel)" = "${VIM_SOURCE_DIR}" ]; then
@ -103,6 +103,8 @@ get_vim_sources() {
else else
msg_err "Could not update Vim sources; ignoring error." msg_err "Could not update Vim sources; ignoring error."
fi fi
else
cd "${VIM_SOURCE_DIR}"
fi fi
} }
@ -124,7 +126,7 @@ find_git_remote() {
} }
# Assign variables for a given Vim tag, patch version, or commit. # Assign variables for a given Vim tag, patch version, or commit.
# Might exit in case it cannot be found. # Might exit in case it cannot be found, after updating Vim sources.
assign_commit_details() { assign_commit_details() {
local vim_commit_ref local vim_commit_ref
if [[ ${1} =~ v?[0-9]\.[0-9]\.[0-9]{3,4} ]]; then if [[ ${1} =~ v?[0-9]\.[0-9]\.[0-9]{3,4} ]]; then
@ -146,9 +148,14 @@ assign_commit_details() {
local munge_commit_line=false local munge_commit_line=false
fi fi
vim_commit=$(git -C "${VIM_SOURCE_DIR}" log -1 --format="%H" "${vim_commit_ref}" --) || { local get_vim_commit_cmd="git -C ${VIM_SOURCE_DIR} log -1 --format=%H ${vim_commit_ref} --"
>&2 msg_err "Couldn't find Vim revision '${vim_commit_ref}'." vim_commit=$($get_vim_commit_cmd 2>&1) || {
exit 3 # Update Vim sources.
get_vim_sources update
vim_commit=$($get_vim_commit_cmd 2>&1) || {
>&2 msg_err "Couldn't find Vim revision '${vim_commit_ref}': git error: ${vim_commit}."
exit 3
}
} }
vim_commit_url="https://github.com/vim/vim/commit/${vim_commit}" vim_commit_url="https://github.com/vim/vim/commit/${vim_commit}"
@ -478,8 +485,8 @@ list_missing_vimpatches() {
# Prints a human-formatted list of Vim commits, with instructional messages. # Prints a human-formatted list of Vim commits, with instructional messages.
# Passes "$@" onto list_missing_vimpatches (args for git-log). # Passes "$@" onto list_missing_vimpatches (args for git-log).
show_vimpatches() { show_vimpatches() {
get_vim_sources get_vim_sources update
printf "\nVim patches missing from Neovim:\n" printf "Vim patches missing from Neovim:\n"
local -A runtime_commits local -A runtime_commits
for commit in $(git -C "${VIM_SOURCE_DIR}" log --format="%H %D" -- runtime | sed 's/,\? tag: / /g'); do for commit in $(git -C "${VIM_SOURCE_DIR}" log --format="%H %D" -- runtime | sed 's/,\? tag: / /g'); do
@ -494,17 +501,12 @@ show_vimpatches() {
fi fi
done done
printf "Instructions: printf "\nInstructions:
To port one of the above patches to Neovim, execute this script with the patch revision as argument and follow the instructions, e.g.
To port one of the above patches to Neovim, execute '%s -p v8.0.1234', or '%s -P v8.0.1234'
this script with the patch revision as argument and
follow the instructions.
Examples: '%s -p 7.4.487'
'%s -p 1e8ebf870720e7b671f98f22d653009826304c4f'
NOTE: Please port the _oldest_ patch if you possibly can. NOTE: Please port the _oldest_ patch if you possibly can.
Out-of-order patches increase the possibility of bugs. You can use '%s -l path/to/file' to see what patches are missing for a file.
" "${BASENAME}" "${BASENAME}" " "${BASENAME}" "${BASENAME}"
} }
@ -646,7 +648,7 @@ while getopts "hlLMVp:P:g:r:s" opt; do
exit 0 exit 0
;; ;;
V) V)
get_vim_sources get_vim_sources update
exit 0 exit 0
;; ;;
*) *)