aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/gen_api_vimdoc.py19
-rwxr-xr-xscripts/genappimage.sh20
-rwxr-xr-xscripts/pvscheck.sh4
-rwxr-xr-xscripts/run-api-tests.exp50
-rwxr-xr-xscripts/shadacat.py2
-rwxr-xr-xscripts/vim-patch.sh224
-rwxr-xr-xscripts/vimpatch.lua67
7 files changed, 236 insertions, 150 deletions
diff --git a/scripts/gen_api_vimdoc.py b/scripts/gen_api_vimdoc.py
index 51e585a007..69f70f6e2b 100644
--- a/scripts/gen_api_vimdoc.py
+++ b/scripts/gen_api_vimdoc.py
@@ -45,6 +45,8 @@ if sys.version_info[0] < 3:
doc_filename = 'api.txt'
# String used to find the start of the generated part of the doc.
section_start_token = '*api-global*'
+# Required prefix for API function names.
+api_func_name_prefix = 'nvim_'
# Section name overrides.
section_name = {
@@ -260,11 +262,11 @@ def parse_parblock(parent, width=62):
def parse_source_xml(filename):
"""Collects API functions.
- This returns two strings:
- 1. The API functions
- 2. The deprecated API functions
+ Returns two strings:
+ 1. API functions
+ 2. Deprecated API functions
- The caller decides what to do with the deprecated documentation.
+ Caller decides what to do with the deprecated documentation.
"""
global xrefs
xrefs = set()
@@ -294,9 +296,8 @@ def parse_source_xml(filename):
annotations = get_text(get_child(member, 'argsstring'))
if annotations and ')' in annotations:
annotations = annotations.rsplit(')', 1)[-1].strip()
- # XXX: (doxygen 1.8.11) 'argsstring' only includes FUNC_ATTR_*
- # attributes if the function signature is non-void.
- # Force attributes here for such functions.
+ # XXX: (doxygen 1.8.11) 'argsstring' only includes attributes of
+ # non-void functions. Special-case void functions here.
if name == 'nvim_get_mode' and len(annotations) == 0:
annotations += 'FUNC_API_ASYNC'
annotations = filter(None, map(lambda x: annotation_map.get(x),
@@ -379,7 +380,7 @@ def parse_source_xml(filename):
if 'Deprecated' in xrefs:
deprecated_functions.append(func_doc)
- else:
+ elif name.startswith(api_func_name_prefix):
functions.append(func_doc)
xrefs.clear()
@@ -477,7 +478,7 @@ def gen_docs(config):
docs += '\n\n\n'
docs = docs.rstrip() + '\n\n'
- docs += ' vim:tw=78:ts=8:ft=help:norl:'
+ docs += ' vim:tw=78:ts=8:ft=help:norl:\n'
doc_file = os.path.join(base_dir, 'runtime/doc', doc_filename)
delete_lines_below(doc_file, section_start_token)
diff --git a/scripts/genappimage.sh b/scripts/genappimage.sh
index a73ccd86c7..2c10ed7202 100755
--- a/scripts/genappimage.sh
+++ b/scripts/genappimage.sh
@@ -11,6 +11,8 @@ if [ -z "$ARCH" ]; then
export ARCH="$(arch)"
fi
+TAG=$1
+
# App name, used by generate_appimage.
APP=nvim
@@ -35,7 +37,7 @@ VERSION=$("$ROOT_DIR"/build/bin/nvim --version | head -n 1 | grep -o 'v.*')
cd "$APP_BUILD_DIR"
-curl -Lo "$APP_BUILD_DIR"/appimage_functions.sh https://github.com/probonopd/AppImages/raw/master/functions.sh
+curl -Lo "$APP_BUILD_DIR"/appimage_functions.sh https://github.com/AppImage/AppImages/raw/master/functions.sh
. ./appimage_functions.sh
# Copy desktop and icon file to AppDir for AppRun to pick them up.
@@ -53,7 +55,7 @@ move_lib
# Delete stuff that should not go into the AppImage.
# Delete dangerous libraries; see
-# https://github.com/probonopd/AppImages/blob/master/excludelist
+# https://github.com/AppImage/AppImages/blob/master/excludelist
delete_blacklisted
########################################################################
@@ -69,14 +71,16 @@ cd "$APP_BUILD_DIR" # Get out of AppImage directory.
# - Expects: $ARCH, $APP, $VERSION env vars
# - Expects: ./$APP.AppDir/ directory
# - Produces: ../out/$APP-$VERSION.glibc$GLIBC_NEEDED-$ARCH.AppImage
-generate_appimage
+if [ -n "$TAG" ]; then
+ generate_type2_appimage -u "gh-releases-zsync|neovim|neovim|$TAG|nvim.appimage.zsync"
+else
+ generate_type2_appimage
+fi
-# NOTE: There is currently a bug in the `generate_appimage` function (see
-# https://github.com/probonopd/AppImages/issues/228) that causes repeated builds
-# that result in the same name to fail.
-# Moving the final executable to a different folder gets around this issue.
+# Moving the final executable to a different folder so it isn't in the
+# way for a subsequent build.
-mv "$ROOT_DIR"/out/*.AppImage "$ROOT_DIR"/build/bin
+mv "$ROOT_DIR"/out/*.AppImage* "$ROOT_DIR"/build/bin
# Remove the (now empty) folder the AppImage was built in
rmdir "$ROOT_DIR"/out
diff --git a/scripts/pvscheck.sh b/scripts/pvscheck.sh
index 30c4d296d7..314966f6aa 100755
--- a/scripts/pvscheck.sh
+++ b/scripts/pvscheck.sh
@@ -343,13 +343,15 @@ run_analysis() {(
cd "$tgt"
+ # pvs-studio-analyzer exits with a non-zero exit code when there are detected
+ # errors, so ignore its return
pvs-studio-analyzer \
analyze \
--threads "$(get_jobs_num)" \
--output-file PVS-studio.log \
--verbose \
--file build/compile_commands.json \
- --sourcetree-root .
+ --sourcetree-root . || true
plog-converter -t xml -o PVS-studio.xml PVS-studio.log
plog-converter -t errorfile -o PVS-studio.err PVS-studio.log
diff --git a/scripts/run-api-tests.exp b/scripts/run-api-tests.exp
deleted file mode 100755
index 27c9c963e5..0000000000
--- a/scripts/run-api-tests.exp
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/env expect
-
-if {$argc < 2} {
- puts "Need commands for running the tests and for starting nvim"
- exit 1
-}
-
-set timeout 60
-set run_tests [split [lindex $argv 0] " "]
-set run_nvim [split [lindex $argv 1] " "]
-
-# don't echo to stdout
-log_user 0
-# set NVIM_LISTEN_ADDRESS, so nvim will listen on a known socket
-set env(NVIM_LISTEN_ADDRESS) "/tmp/nvim-[exec date +%s%N].sock"
-# start nvim
-spawn {*}$run_nvim
-# save the job descriptor
-set nvim_id $spawn_id
-# Reset function that can be invoked by test runners to put nvim in a cleaner
-# state
-send {
-:echo "read"."y"
-}
-# wait until nvim is ready
-expect "ready"
-# run tests
-spawn {*}$run_tests
-set tests_id $spawn_id
-set status 1
-# listen for test output in the background
-expect_background {
- * {
- # show test output to the user
- send_user -- $expect_out(buffer)
- }
- eof {
- # collect the exit status code
- set spawn_id $tests_id
- catch wait result
- set status [lindex $result 3]
- set spawn_id $nvim_id
- # quit nvim
- send ":qa!\r"
- }
-}
-# switch back nvim and wait until it exits
-set spawn_id $nvim_id
-expect eof
-exit $status
diff --git a/scripts/shadacat.py b/scripts/shadacat.py
index 2f2cf19f9d..522379aad4 100755
--- a/scripts/shadacat.py
+++ b/scripts/shadacat.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3.4
+#!/usr/bin/env python3
import os
import sys
diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh
index 2875e7d95a..5182756d83 100755
--- a/scripts/vim-patch.sh
+++ b/scripts/vim-patch.sh
@@ -14,26 +14,34 @@ readonly BRANCH_PREFIX="vim-"
CREATED_FILES=()
usage() {
- echo "Helper script for porting Vim patches. For more information, see"
+ echo "Port Vim patches to Neovim"
echo "https://github.com/neovim/neovim/wiki/Merging-patches-from-upstream-vim"
echo
echo "Usage: ${BASENAME} [-h | -l | -p vim-revision | -r pr-number]"
echo
echo "Options:"
echo " -h Show this message and exit."
- echo " -l Show list of Vim patches missing from Neovim."
- echo " -p {vim-revision} Download and generate the specified Vim patch."
- echo " vim-revision can be a version number '8.0.xxx'"
- echo " or a valid Git ref (hash, tag, etc.)."
- echo " -P {vim-revision} Download, generate and apply the Vim patch."
- echo " -g {vim-revision} Download the Vim patch vim-revision."
- echo " vim-revision can be a version number of the "
- echo " format '7.4.xxx' or a Git commit hash."
- echo " -s Submit a vim-patch pull request to Neovim."
- echo " -r {pr-number} Review a vim-patch pull request to Neovim."
+ echo " -l List missing Vim patches."
+ echo " -L List missing Vim patches (for scripts)."
+ echo " -M List all merged patch-numbers (at current v:version)."
+ echo " -p {vim-revision} Download and generate a Vim patch. vim-revision"
+ echo " can be a Vim version (8.0.xxx) or a Git hash."
+ echo " -P {vim-revision} Download, generate and apply a Vim patch."
+ echo " -g {vim-revision} Download a Vim patch."
+ echo " -s Create a vim-patch pull request."
+ echo " -r {pr-number} Review a vim-patch pull request."
+ echo ' -V Clone the Vim source code to $VIM_SOURCE_DIR.'
echo
- echo "Set VIM_SOURCE_DIR to change where Vim's sources are stored."
- echo "Default is '${VIM_SOURCE_DIR_DEFAULT}'."
+ echo ' $VIM_SOURCE_DIR controls where Vim sources are found'
+ echo " (default: '${VIM_SOURCE_DIR_DEFAULT}')"
+}
+
+msg_ok() {
+ printf "\e[32m✔\e[0m $@\n"
+}
+
+msg_err() {
+ printf "\e[31m✘\e[0m $@\n"
}
# Checks if a program is in the user's PATH, and is executable.
@@ -73,26 +81,29 @@ get_vim_sources() {
require_executable git
if [[ ! -d ${VIM_SOURCE_DIR} ]]; then
- echo "Cloning Vim sources into '${VIM_SOURCE_DIR}'."
+ echo "Cloning Vim into: ${VIM_SOURCE_DIR}"
git clone https://github.com/vim/vim.git "${VIM_SOURCE_DIR}"
cd "${VIM_SOURCE_DIR}"
else
if [[ ! -d "${VIM_SOURCE_DIR}/.git" ]]; then
- echo "✘ ${VIM_SOURCE_DIR} does not appear to be a git repository."
+ msg_err "${VIM_SOURCE_DIR} does not appear to be a git repository."
echo " Please remove it and try again."
exit 1
fi
cd "${VIM_SOURCE_DIR}"
- echo "Updating Vim sources in '${VIM_SOURCE_DIR}'."
+ echo "Updating Vim sources: ${VIM_SOURCE_DIR}"
git pull &&
- echo "✔ Updated Vim sources." ||
- echo "✘ Could not update Vim sources; ignoring error."
+ msg_ok "Updated Vim sources." ||
+ msg_err "Could not update Vim sources; ignoring error."
fi
}
commit_message() {
- printf 'vim-patch:%s\n\n%s\n\n%s' "${vim_version}" \
- "${vim_message}" "${vim_commit_url}"
+ if [[ -n "$vim_tag" ]]; then
+ printf '%s\n%s' "${vim_message}" "${vim_commit_url}"
+ else
+ printf 'vim-patch:%s\n\n%s\n%s' "$vim_version" "$vim_message" "$vim_commit_url"
+ fi
}
find_git_remote() {
@@ -107,22 +118,23 @@ assign_commit_details() {
vim_tag="v${1}"
vim_commit=$(cd "${VIM_SOURCE_DIR}" \
&& git log -1 --format="%H" "${vim_tag}")
- local strip_commit_line=true
+ local munge_commit_line=true
else
# Interpret parameter as commit hash.
vim_version="${1:0:12}"
+ vim_tag=
vim_commit=$(cd "${VIM_SOURCE_DIR}" \
&& git log -1 --format="%H" "${vim_version}")
- local strip_commit_line=false
+ local munge_commit_line=false
fi
vim_commit_url="https://github.com/vim/vim/commit/${vim_commit}"
vim_message="$(cd "${VIM_SOURCE_DIR}" \
&& git log -1 --pretty='format:%B' "${vim_commit}" \
| sed -e 's/\(#[0-9]*\)/vim\/vim\1/g')"
- if [[ ${strip_commit_line} == "true" ]]; then
+ if [[ ${munge_commit_line} == "true" ]]; then
# Remove first line of commit message.
- vim_message="$(echo "${vim_message}" | sed -e '1d')"
+ vim_message="$(echo "${vim_message}" | sed -e '1s/^patch /vim-patch:/')"
fi
patch_file="vim-${vim_version}.patch"
}
@@ -147,6 +159,10 @@ preprocess_patch() {
local na_src_testdir='Make_amiga.mak\|Make_dos.mak\|Make_ming.mak\|Make_vms.mms'
2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/testdir/\<\%('${na_src_testdir}'\)\>@norm! d/\v(^diff)|%$ ' +w +q "$file"
+ # Remove version.c #7555
+ local na_po='version.c'
+ 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/\<\%('${na_po}'\)\>@norm! d/\v(^diff)|%$ ' +w +q "$file"
+
# Remove some *.po files. #5622
local na_po='sjiscorr.c\|ja.sjis.po\|ko.po\|pl.cp1250.po\|pl.po\|ru.cp1251.po\|uk.cp1251.po\|zh_CN.cp936.po\|zh_CN.po\|zh_TW.po'
2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/po/\<\%('${na_po}'\)\>@norm! d/\v(^diff)|%$ ' +w +q "$file"
@@ -164,16 +180,16 @@ preprocess_patch() {
"$file" > "$file".tmp && mv "$file".tmp "$file"
}
-get_vim_patch() {
+get_vimpatch() {
get_vim_sources
assign_commit_details "${1}"
git log -1 "${vim_commit}" -- >/dev/null 2>&1 || {
- >&2 echo "✘ Couldn't find Vim revision '${vim_commit}'."
+ >&2 msg_err "Couldn't find Vim revision '${vim_commit}'."
exit 3
}
- echo "✔ Found Vim revision '${vim_commit}'."
+ msg_ok "Found Vim revision '${vim_commit}'."
local patch_content
patch_content="$(git --no-pager show --color=never -1 --pretty=medium "${vim_commit}")"
@@ -186,11 +202,11 @@ get_vim_patch() {
printf "Pre-processing patch...\n"
preprocess_patch "${NVIM_SOURCE_DIR}/${patch_file}"
- printf "✔ Saved patch to '${NVIM_SOURCE_DIR}/${patch_file}'.\n"
+ msg_ok "Saved patch to '${NVIM_SOURCE_DIR}/${patch_file}'.\n"
}
stage_patch() {
- get_vim_patch "$1"
+ get_vimpatch "$1"
local try_apply="${2:-}"
local git_remote
@@ -199,34 +215,36 @@ stage_patch() {
checked_out_branch="$(git rev-parse --abbrev-ref HEAD)"
if [[ "${checked_out_branch}" == ${BRANCH_PREFIX}* ]]; then
- echo "✔ Current branch '${checked_out_branch}' seems to be a vim-patch"
+ msg_ok "Current branch '${checked_out_branch}' seems to be a vim-patch"
echo " branch; not creating a new branch."
else
printf "\nFetching '${git_remote}/master'.\n"
output="$(git fetch "${git_remote}" master 2>&1)" &&
- echo "✔ ${output}" ||
- (echo "✘ ${output}"; false)
+ msg_ok "${output}" ||
+ (msg_err "${output}"; false)
local nvim_branch="${BRANCH_PREFIX}${vim_version}"
echo
echo "Creating new branch '${nvim_branch}' based on '${git_remote}/master'."
cd "${NVIM_SOURCE_DIR}"
output="$(git checkout -b "${nvim_branch}" "${git_remote}/master" 2>&1)" &&
- echo "✔ ${output}" ||
- (echo "✘ ${output}"; false)
+ msg_ok "${output}" ||
+ (msg_err "${output}"; false)
fi
printf "\nCreating empty commit with correct commit message.\n"
output="$(commit_message | git commit --allow-empty --file 2>&1 -)" &&
- echo "✔ ${output}" ||
- (echo "✘ ${output}"; false)
+ msg_ok "${output}" ||
+ (msg_err "${output}"; false)
if test -n "$try_apply" ; then
if ! check_executable patch; then
- printf "\n✘ 'patch' command not found\n"
+ printf "\n"
+ msg_err "'patch' command not found\n"
else
printf "\nApplying patch...\n"
- patch -p1 --posix < "${patch_file}"
+ patch -p1 < "${patch_file}" || true
+ find -name '*.orig' -type f -delete
fi
printf "\nInstructions:\n Proceed to port the patch.\n"
else
@@ -274,16 +292,17 @@ submit_pr() {
local checked_out_branch
checked_out_branch="$(git rev-parse --abbrev-ref HEAD)"
if [[ "${checked_out_branch}" != ${BRANCH_PREFIX}* ]]; then
- echo "✘ Current branch '${checked_out_branch}' doesn't seem to be a vim-patch branch."
+ msg_err "Current branch '${checked_out_branch}' doesn't seem to be a vim-patch branch."
exit 1
fi
local git_remote
git_remote="$(find_git_remote)"
local pr_body
- pr_body="$(git log --reverse --format='#### %s%n%n%b%n' "${git_remote}"/master..HEAD)"
+ pr_body="$(git log --grep=vim-patch --reverse --format='#### %s%n%n%b%n' "${git_remote}"/master..HEAD)"
local patches
- patches=("$(git log --reverse --format='%s' "${git_remote}"/master..HEAD)")
+ # Extract just the "vim-patch:X.Y.ZZZZ" or "vim-patch:sha" portion of each log
+ patches=("$(git log --grep=vim-patch --reverse --format='%s' "${git_remote}"/master..HEAD | sed 's/: .*//')")
patches=(${patches[@]//vim-patch:}) # Remove 'vim-patch:' prefix for each item in array.
local pr_title="${patches[*]}" # Create space-separated string from array.
pr_title="${pr_title// /,}" # Replace spaces with commas.
@@ -294,16 +313,16 @@ submit_pr() {
if [[ $push_first -ne 0 ]]; then
echo "Pushing to 'origin/${checked_out_branch}'."
output="$(git push origin "${checked_out_branch}" 2>&1)" &&
- echo "✔ ${output}" ||
- (echo "✘ ${output}"; false)
+ msg_ok "${output}" ||
+ (msg_err "${output}"; false)
echo
fi
echo "Creating pull request."
output="$(${submit_fn} "${pr_message}" 2>&1)" &&
- echo "✔ ${output}" ||
- (echo "✘ ${output}"; false)
+ msg_ok "${output}" ||
+ (msg_err "${output}"; false)
echo
echo "Cleaning up files."
@@ -314,43 +333,74 @@ submit_pr() {
continue
fi
rm -- "${NVIM_SOURCE_DIR}/${patch_file}"
- echo "✔ Removed '${NVIM_SOURCE_DIR}/${patch_file}'."
+ msg_ok "Removed '${NVIM_SOURCE_DIR}/${patch_file}'."
done
}
-list_vim_patches() {
- get_vim_sources
+# Gets all Vim commits since the "start" commit.
+list_vim_commits() { (
+ 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.
+list_vimpatch_tokens() {
+ local tokens
+ # Find all "vim-patch:xxx" tokens in the Nvim git log.
+ tokens="$(cd "${NVIM_SOURCE_DIR}" && git log -E --grep='vim-patch:[^ ]+' | grep 'vim-patch')"
+ echo "$tokens" | grep -E 'vim-patch:[^ ,{]{7,}' \
+ | sed 's/.*\(vim-patch:[.0-9a-z]\+\).*/\1/' \
+ | sort \
+ | uniq
+}
- printf "\nVim patches missing from Neovim:\n"
+# Prints all patch-numbers (for the current v:version) for which there is
+# a "vim-patch:xxx" token in the Nvim git log.
+list_vimpatch_numbers() {
+ # Transform "vim-patch:X.Y.ZZZZ" to "ZZZZ".
+ list_vimpatch_tokens | while read vimpatch_token; do
+ echo "$vimpatch_token" | grep '8\.0\.' | sed 's/.*vim-patch:8\.0\.\([0-9a-z]\+\).*/\1/'
+ done
+}
- # Get missing Vim commits
- local vim_commits
- vim_commits="$(cd "${VIM_SOURCE_DIR}" && git log --reverse --format='%H' v8.0.0000..HEAD)"
+# Prints a newline-delimited list of Vim commits, for use by scripts.
+list_missing_vimpatches() {
+ local tokens vim_commit vim_commits is_missing vim_tag patch_number
+
+ # Find all "vim-patch:xxx" tokens in the Nvim git log.
+ tokens="$(list_vimpatch_tokens)"
- local vim_commit
+ # Get missing Vim commits
+ vim_commits="$(list_vim_commits)"
for vim_commit in ${vim_commits}; do
- local is_missing
- local vim_tag
- # 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
- if [[ -n "${vim_tag}" ]]; then
- local patch_number="${vim_tag:5}" # Remove prefix like "v7.4."
- patch_number="$(echo ${patch_number} | sed 's/^0*//g')" # Remove prefix "0"
- # Tagged Vim patch, check version.c:
- is_missing="$(sed -n '/static const int included_patches/,/}/p' "${NVIM_SOURCE_DIR}/src/nvim/version.c" |
- grep -x -e "[[:space:]]*//[[:space:]]${patch_number} NA.*" -e "[[:space:]]*${patch_number}," >/dev/null && echo "false" || echo "true")"
+ # 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)"
+ then
+ # Vim version number (not commit hash).
+ # Check for vim-patch:<tag> (not commit hash).
+ 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 (cd "${VIM_SOURCE_DIR}" && git --no-pager show --color=never --name-only "v${vim_commit}" 2>/dev/null) | grep -q ^runtime; then
- vim_commit="${vim_commit} (+runtime)"
- fi
- else
- # Untagged Vim patch (e.g. runtime updates), check the Neovim git log:
- is_missing="$(cd "${NVIM_SOURCE_DIR}" &&
- git log -1 --no-merges --grep="vim\-patch:${vim_commit:0:7}" --pretty=format:false)"
fi
- if [[ ${is_missing} != "false" ]]; then
- echo " • ${vim_commit}"
+ if ! [ "$is_missing" = "false" ]; then
+ echo "${vim_commit}"
+ fi
+ done
+}
+
+# Prints a human-formatted list of Vim commits, with instructional messages.
+show_vimpatches() {
+ get_vim_sources
+ printf "\nVim patches missing from Neovim:\n"
+
+ list_missing_vimpatches | 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
+ printf " • ${vim_commit} (+runtime)\n"
+ else
+ printf " • ${vim_commit}\n"
fi
done
@@ -380,9 +430,9 @@ review_commit() {
echo
if [[ -n "${vim_version}" ]]; then
- echo "✔ Detected Vim patch '${vim_version}'."
+ msg_ok "Detected Vim patch '${vim_version}'."
else
- echo "✘ Could not detect the Vim patch number."
+ msg_err "Could not detect the Vim patch number."
echo " This script assumes that the PR contains only commits"
echo " with 'vim-patch:XXX' in their title."
echo
@@ -405,9 +455,9 @@ review_commit() {
local commit_message
commit_message="$(tail -n +4 <<< "${nvim_patch}" | head -n "${message_length}")"
if [[ "${commit_message#${git_patch_prefix}}" == "${expected_commit_message}" ]]; then
- echo "✔ Found expected commit message."
+ msg_ok "Found expected commit message."
else
- echo "✘ Wrong commit message."
+ msg_err "Wrong commit message."
echo " Expected:"
echo "${expected_commit_message}"
echo " Actual:"
@@ -417,10 +467,10 @@ review_commit() {
echo
echo "Creating files."
echo "${nvim_patch}" > "${NVIM_SOURCE_DIR}/n${patch_file}"
- echo "✔ Saved pull request diff to '${NVIM_SOURCE_DIR}/n${patch_file}'."
+ msg_ok "Saved pull request diff to '${NVIM_SOURCE_DIR}/n${patch_file}'."
CREATED_FILES+=("${NVIM_SOURCE_DIR}/n${patch_file}")
- get_vim_patch "${vim_version}"
+ get_vimpatch "${vim_version}"
CREATED_FILES+=("${NVIM_SOURCE_DIR}/${patch_file}")
echo
@@ -461,14 +511,22 @@ review_pr() {
clean_files
}
-while getopts "hlp:P:g:r:s" opt; do
+while getopts "hlLMVp:P:g:r:s" opt; do
case ${opt} in
h)
usage
exit 0
;;
l)
- list_vim_patches
+ show_vimpatches
+ exit 0
+ ;;
+ L)
+ list_missing_vimpatches
+ exit 0
+ ;;
+ M)
+ list_vimpatch_numbers
exit 0
;;
p)
@@ -480,7 +538,7 @@ while getopts "hlp:P:g:r:s" opt; do
exit 0
;;
g)
- get_vim_patch "${OPTARG}"
+ get_vimpatch "${OPTARG}"
exit 0
;;
r)
@@ -491,6 +549,10 @@ while getopts "hlp:P:g:r:s" opt; do
submit_pr
exit 0
;;
+ V)
+ get_vim_sources
+ exit 0
+ ;;
*)
exit 1
;;
diff --git a/scripts/vimpatch.lua b/scripts/vimpatch.lua
new file mode 100755
index 0000000000..0924f3d718
--- /dev/null
+++ b/scripts/vimpatch.lua
@@ -0,0 +1,67 @@
+-- Updates version.c list of applied Vim patches.
+--
+-- Usage:
+-- VIM_SOURCE_DIR=~/neovim/.vim-src/ nvim -i NONE -u NONE --headless +'luafile ./scripts/vimpatch.lua' +q
+
+local nvim = vim.api
+
+local function pprint(o)
+ print(nvim.nvim_call_function('string', { o }))
+end
+
+local function systemlist(...)
+ local rv = nvim.nvim_call_function('systemlist', ...)
+ local err = nvim.nvim_get_vvar('shell_error')
+ local args_str = nvim.nvim_call_function('string', ...)
+ if 0 ~= err then
+ error('command failed: '..args_str)
+ end
+ return rv
+end
+
+local function vimpatch_sh_list_numbers()
+ return systemlist( { { 'bash', '-c', 'scripts/vim-patch.sh -M', } } )
+end
+
+-- Generates the lines to be inserted into the src/version.c
+-- `included_patches[]` definition.
+local function gen_version_c_lines()
+ -- Set of merged Vim 8.0.zzzz patch numbers.
+ local merged_patch_numbers = {}
+ local highest = 0
+ for _, n in ipairs(vimpatch_sh_list_numbers()) do
+ if n then
+ merged_patch_numbers[tonumber(n)] = true
+ highest = math.max(highest, n)
+ end
+ end
+
+ local lines = {}
+ for i = highest, 0, -1 do
+ local is_merged = (nil ~= merged_patch_numbers[i])
+ if is_merged then
+ table.insert(lines, string.format(' %s,', i))
+ else
+ table.insert(lines, string.format(' // %s,', i))
+ end
+ end
+
+ return lines
+end
+
+local function patch_version_c()
+ local lines = gen_version_c_lines()
+
+ nvim.nvim_command('silent noswapfile noautocmd edit src/nvim/version.c')
+ nvim.nvim_command('/static const int included_patches')
+ -- Delete the existing lines.
+ nvim.nvim_command('silent normal! j0d/};\rk')
+ -- Insert the lines.
+ nvim.nvim_call_function('append', {
+ nvim.nvim_eval('line(".")'),
+ lines,
+ })
+ nvim.nvim_command('silent write')
+end
+
+patch_version_c()