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

View File

@@ -89,7 +89,7 @@ get_vim_sources() {
echo "Cloning Vim into: ${VIM_SOURCE_DIR}"
git clone https://github.com/vim/vim.git "${VIM_SOURCE_DIR}"
cd "${VIM_SOURCE_DIR}"
else
elif [[ "${1-}" == update ]]; then
cd "${VIM_SOURCE_DIR}"
if ! [ -d ".git" ] \
&& ! [ "$(git rev-parse --show-toplevel)" = "${VIM_SOURCE_DIR}" ]; then
@@ -103,6 +103,8 @@ get_vim_sources() {
else
msg_err "Could not update Vim sources; ignoring error."
fi
else
cd "${VIM_SOURCE_DIR}"
fi
}
@@ -124,7 +126,7 @@ find_git_remote() {
}
# 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() {
local vim_commit_ref
if [[ ${1} =~ v?[0-9]\.[0-9]\.[0-9]{3,4} ]]; then
@@ -146,9 +148,14 @@ assign_commit_details() {
local munge_commit_line=false
fi
vim_commit=$(git -C "${VIM_SOURCE_DIR}" log -1 --format="%H" "${vim_commit_ref}" --) || {
>&2 msg_err "Couldn't find Vim revision '${vim_commit_ref}'."
exit 3
local get_vim_commit_cmd="git -C ${VIM_SOURCE_DIR} log -1 --format=%H ${vim_commit_ref} --"
vim_commit=$($get_vim_commit_cmd 2>&1) || {
# 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}"
@@ -478,8 +485,8 @@ list_missing_vimpatches() {
printf '%s%s\n' "$vim_commit" "$info"
fi
done < <(list_vim_commits "${git_log_args[@]}")
set -u
}
set -u
}
# Prints a human-formatted list of Vim commits, with instructional messages.
# Passes "$@" onto list_missing_vimpatches (args for git-log).
@@ -494,17 +501,12 @@ show_vimpatches() {
list_missing_vimpatches 1 "$@" | while read -r vim_commit; do
if [[ "${runtime_commits[$vim_commit]-}" ]]; then
printf ' • %s (+runtime)\n' "${vim_commit}"
else
printf ' • %s\n' "${vim_commit}"
fi
done
printf "Instructions:
printf ' • %s (+runtime)\n' "${vim_commit}"
else
printf ' • %s\n' "${vim_commit}"
fi
done
follow the 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.
'%s -p v8.0.1234', or '%s -P v8.0.1234'
@@ -646,7 +648,7 @@ while getopts "hlLMVp:P:g:r:s" opt; do
r)
review_pr "${OPTARG}"
exit 0
;;
;;
s)
submit_pr
exit 0