vim-patch.sh: introduce -L

This commit is contained in:
Justin M. Keyes
2017-12-11 00:49:44 +01:00
parent e9504b7fd8
commit 56b49955b7

View File

@@ -21,7 +21,8 @@ usage() {
echo echo
echo "Options:" echo "Options:"
echo " -h Show this message and exit." echo " -h Show this message and exit."
echo " -l Show list of Vim patches missing from Neovim." echo " -l Show list of missing Vim patches."
echo " -L Print missing Vim patches in machine-readable form."
echo " -p {vim-revision} Download and generate the specified Vim patch." echo " -p {vim-revision} Download and generate the specified Vim patch."
echo " vim-revision can be a version number '8.0.xxx'" echo " vim-revision can be a version number '8.0.xxx'"
echo " or a valid Git ref (hash, tag, etc.)." echo " or a valid Git ref (hash, tag, etc.)."
@@ -318,11 +319,8 @@ submit_pr() {
if [[ ! -f "${NVIM_SOURCE_DIR}/${patch_file}" ]]; then if [[ ! -f "${NVIM_SOURCE_DIR}/${patch_file}" ]]; then
continue continue
fi fi
rm -- "${NVIM_SOURCE_DIR}/${patch_file}"
echo "✔ Removed '${NVIM_SOURCE_DIR}/${patch_file}'." echo "✔ Removed '${NVIM_SOURCE_DIR}/${patch_file}'."
echo "✔ Removed '${NVIM_SOURCE_DIR}/${patch_file}'."
done
}
done done
} }
@@ -343,18 +341,27 @@ list_vim_patches() {
local vim_tag local vim_tag
# This fails for untagged commits (e.g., runtime file updates) so mask the return status # This fails for untagged commits (e.g., runtime file updates) so mask the return status
vim_tag="$(cd "${VIM_SOURCE_DIR}" && git describe --tags --exact-match "${vim_commit}" 2>/dev/null)" || true vim_tag="$(cd "${VIM_SOURCE_DIR}" && git describe --tags --exact-match "${vim_commit}" 2>/dev/null)" || true
if [[ -n "${vim_tag}" ]]; then
# Vim version number (not commit hash).
local patch_number="${vim_tag:1}" # "v7.4.0001" => "7.4.0001"
is_missing="$(echo "$tokens" | >/dev/null 2>&1 grep "vim\-patch:${patch_number}" && echo false || echo true)"
vim_commit="${vim_tag#v}"
if [[ -n "${vim_tag}" ]]; then if [[ -n "${vim_tag}" ]]; then
# Vim version number (not commit hash). # Vim version number (not commit hash).
local patch_number="${vim_tag:1}" # "v7.4.0001" => "7.4.0001" local patch_number="${vim_tag:1}" # "v7.4.0001" => "7.4.0001"
is_missing="$(echo "$tokens" | >/dev/null 2>&1 grep "vim\-patch:${patch_number}" && echo false || echo true)" is_missing="$(echo "$tokens" | >/dev/null 2>&1 grep "vim\-patch:${patch_number}" && echo false || echo true)"
vim_commit="${vim_tag#v}" vim_commit="${vim_tag#v}"
else else
# Untagged Vim patch (e.g. runtime updates). # Untagged Vim patch (e.g. runtime updates).
is_missing="$(echo "$tokens" | >/dev/null 2>&1 grep "vim\-patch:${vim_commit:0:7}" && echo false || echo true)"
fi
if ! [ "$is_missing" = "false" ]; then
echo "${vim_commit}"
fi
done
}
# Prints a human-formatted list of Vim commits, with instructional messages.
show_vim_patches() {
get_vim_sources
printf "\nVim patches missing from Neovim:\n"
list_vim_patches | while read vim_commit; do list_vim_patches | while read vim_commit; do
if (cd "${VIM_SOURCE_DIR}" && git --no-pager show --color=never --name-only "v${vim_commit}" 2>/dev/null) | grep -q ^runtime; then if (cd "${VIM_SOURCE_DIR}" && git --no-pager show --color=never --name-only "v${vim_commit}" 2>/dev/null) | grep -q ^runtime; then
printf "${vim_commit} (+runtime)\n" printf "${vim_commit} (+runtime)\n"
@@ -465,13 +472,17 @@ review_pr() {
break break
fi fi
fi fi
done done
clean_files clean_files
} }
while getopts "hlLp:P:g:r:s" opt; do while getopts "hlLp:P:g:r:s" opt; do
case ${opt} in case ${opt} in
h)
usage
exit 0
;;
l) l)
show_vim_patches show_vim_patches
exit 0 exit 0