aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/gendeclarations.lua2
-rw-r--r--scripts/msgpack-gen.lua11
-rwxr-xr-xscripts/release.sh6
-rwxr-xr-xscripts/vim-patch.sh117
4 files changed, 93 insertions, 43 deletions
diff --git a/scripts/gendeclarations.lua b/scripts/gendeclarations.lua
index 4e74e4e301..ff69b18ae4 100755
--- a/scripts/gendeclarations.lua
+++ b/scripts/gendeclarations.lua
@@ -143,7 +143,7 @@ local pattern = concat(
lit(')'),
any_amount(concat( -- optional attributes
spaces,
- lit('FUNC_ATTR_'),
+ lit('FUNC_'),
any_amount(aw),
one_or_no(concat( -- attribute argument
spaces,
diff --git a/scripts/msgpack-gen.lua b/scripts/msgpack-gen.lua
index c726db3920..190af636dc 100644
--- a/scripts/msgpack-gen.lua
+++ b/scripts/msgpack-gen.lua
@@ -35,7 +35,8 @@ c_proto = Ct(
Cg(c_type, 'return_type') * Cg(c_id, 'name') *
fill * P('(') * fill * Cg(c_params, 'parameters') * fill * P(')') *
Cg(Cc(false), 'async') *
- (fill * Cg((P('FUNC_ATTR_ASYNC') * Cc(true)), 'async') ^ -1) *
+ (fill * Cg((P('FUNC_API_ASYNC') * Cc(true)), 'async') ^ -1) *
+ (fill * Cg((P('FUNC_API_NOEXPORT') * Cc(true)), 'noexport') ^ -1) *
fill * P(';')
)
grammar = Ct((c_proto + c_comment + c_preproc + ws) ^ 1)
@@ -62,8 +63,11 @@ for i = 1, #arg - 1 do
local input = io.open(full_path, 'rb')
local tmp = grammar:match(input:read('*all'))
for i = 1, #tmp do
- functions[#functions + 1] = tmp[i]
local fn = tmp[i]
+ if fn.noexport then
+ goto continue
+ end
+ functions[#functions + 1] = tmp[i]
if #fn.parameters ~= 0 and fn.parameters[1][2] == 'channel_id' then
-- this function should receive the channel id
fn.receives_channel_id = true
@@ -77,6 +81,7 @@ for i = 1, #arg - 1 do
-- for specifying errors
fn.parameters[#fn.parameters] = nil
end
+ ::continue::
end
input:close()
end
@@ -217,7 +222,7 @@ for i = 1, #functions do
if fn.receives_channel_id then
-- if the function receives the channel id, pass it as first argument
- if #args > 0 then
+ if #args > 0 or fn.can_fail then
output:write('channel_id, '..call_args)
else
output:write('channel_id')
diff --git a/scripts/release.sh b/scripts/release.sh
index 514e5b380a..67738ccc96 100755
--- a/scripts/release.sh
+++ b/scripts/release.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/sh
# Performs steps to tag a release.
#
@@ -45,11 +45,11 @@ echo "Most recent tag: ${__LAST_TAG}"
echo "Release version: ${__VERSION}"
sed -i -r 's/(NVIM_VERSION_PRERELEASE) "-dev"/\1 ""/' CMakeLists.txt
echo "Building changelog since ${__LAST_TAG}..."
-__CHANGELOG="$(./scripts/git-log-pretty-since.sh $__LAST_TAG 'vim-patch:\S')"
+__CHANGELOG="$(./scripts/git-log-pretty-since.sh "$__LAST_TAG" 'vim-patch:\S')"
git add CMakeLists.txt
git commit --edit -m "${__RELEASE_MSG} ${__CHANGELOG}"
-git tag -a v${__VERSION} -m "NVIM v${__VERSION}"
+git tag -a v"${__VERSION}" -m "NVIM v${__VERSION}"
sed -i -r 's/(NVIM_VERSION_PRERELEASE) ""/\1 "-dev"/' CMakeLists.txt
nvim -c '/NVIM_VERSION' -c 'echo "Update version numbers"' CMakeLists.txt
diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh
index 70777535cb..62f2b80a82 100755
--- a/scripts/vim-patch.sh
+++ b/scripts/vim-patch.sh
@@ -33,7 +33,11 @@ usage() {
# Checks if a program is in the user's PATH, and is executable.
check_executable() {
- if [[ ! -x $(command -v "${1}") ]]; then
+ test -x "$(command -v "${1}")"
+}
+
+require_executable() {
+ if ! check_executable "${1}"; then
>&2 echo "${BASENAME}: '${1}' not found in PATH or not executable."
exit 1
fi
@@ -47,21 +51,21 @@ clean_files() {
echo
echo "Created files:"
local file
- for file in ${CREATED_FILES[@]}; do
+ for file in "${CREATED_FILES[@]}"; do
echo " • ${file}"
done
read -p "Delete these files (Y/n)? " -n 1 -r reply
echo
if [[ "${reply}" =~ ^[Yy]$ ]]; then
- rm -- ${CREATED_FILES[@]}
+ rm -- "${CREATED_FILES[@]}"
else
echo "You can use 'git clean' to remove these files when you're done."
fi
}
get_vim_sources() {
- check_executable git
+ require_executable git
if [[ ! -d ${VIM_SOURCE_DIR} ]]; then
echo "Cloning Vim sources into '${VIM_SOURCE_DIR}'."
@@ -88,7 +92,7 @@ commit_message() {
find_git_remote() {
git remote -v \
- | awk '$2 ~ /github.com[:/]neovim\/neovim/ && $3 == "(fetch)" {print $1}'
+ | awk '$2 ~ /github.com[:/]neovim\/neovim/ && $3 == "(fetch)" {print $1; exit}'
}
assign_commit_details() {
@@ -97,13 +101,13 @@ assign_commit_details() {
vim_version="${1}"
vim_tag="v${1}"
vim_commit=$(cd "${VIM_SOURCE_DIR}" \
- && git log -1 --format="%H" ${vim_tag})
+ && git log -1 --format="%H" "${vim_tag}")
local strip_commit_line=true
else
# Interpret parameter as commit hash.
vim_version="${1:0:7}"
vim_commit=$(cd "${VIM_SOURCE_DIR}" \
- && git log -1 --format="%H" ${vim_version})
+ && git log -1 --format="%H" "${vim_version}")
local strip_commit_line=false
fi
@@ -132,13 +136,16 @@ get_vim_patch() {
# Patch surgery: preprocess the patch.
# - transform src/ paths to src/nvim/
- local vim_full="$(git show -1 --pretty=medium "${vim_commit}" \
+ local vim_full
+ vim_full="$(git show -1 --pretty=medium "${vim_commit}" \
| LC_ALL=C sed -e 's/\( [ab]\/src\)/\1\/nvim/g')"
local neovim_branch="${BRANCH_PREFIX}${vim_version}"
cd "${NEOVIM_SOURCE_DIR}"
- local git_remote=$(find_git_remote)
- local checked_out_branch="$(git rev-parse --abbrev-ref HEAD)"
+ local git_remote
+ git_remote="$(find_git_remote)"
+ 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}' seems to be a vim-patch"
@@ -191,41 +198,68 @@ get_vim_patch() {
echo " for more information."
}
+hub_pr() {
+ hub pull-request -m "$1"
+}
+
+git_hub_pr() {
+ git hub pull new -m "$1"
+}
+
submit_pr() {
- check_executable git
- check_executable hub
+ require_executable git
+ local push_first
+ push_first=1
+ local submit_fn
+ if check_executable hub; then
+ submit_fn="hub_pr"
+ elif check_executable git-hub; then
+ push_first=0
+ submit_fn="git_hub_pr"
+ else
+ >&2 echo "${BASENAME}: 'hub' or 'git-hub' not found in PATH or not executable."
+ exit 1
+ fi
cd "${NEOVIM_SOURCE_DIR}"
- local checked_out_branch="$(git rev-parse --abbrev-ref HEAD)"
+ 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."
exit 1
fi
- local git_remote=$(find_git_remote)
- local pr_body="$(git log --reverse --format='#### %s%n%n%b%n' ${git_remote}/master..HEAD)"
- local patches=("$(git log --reverse --format='%s' ${git_remote}/master..HEAD)")
+ 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)"
+ local patches
+ patches=("$(git log --reverse --format='%s' "${git_remote}"/master..HEAD)")
patches=(${patches[@]//vim-patch:}) # Remove 'vim-patch:' prefix for each item in array.
- local pr_title="${patches[@]}" # Create space-separated string from array.
+ local pr_title="${patches[*]}" # Create space-separated string from array.
pr_title="${pr_title// /,}" # Replace spaces with commas.
- local pr_message="$(printf '[RFC] vim-patch:%s\n\n%s\n' "${pr_title#,}" "${pr_body}")"
+ local pr_message
+ pr_message="$(printf '[RFC] vim-patch:%s\n\n%s\n' "${pr_title#,}" "${pr_body}")"
- echo "Pushing to 'origin/${checked_out_branch}'."
- output="$(git push origin "${checked_out_branch}" 2>&1)" &&
- echo "✔ ${output}" ||
- (echo "✘ ${output}"; git reset --soft HEAD^1; false)
+ 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}"; git reset --soft HEAD^1; false)
+
+ echo
+ fi
- echo
echo "Creating pull request."
- output="$(hub pull-request -F - 2>&1 <<< "${pr_message}")" &&
+ output="$(${submit_fn} "${pr_message}" 2>&1)" &&
echo "✔ ${output}" ||
(echo "✘ ${output}"; false)
echo
echo "Cleaning up files."
local patch_file
- for patch_file in ${patches[@]}; do
+ for patch_file in "${patches[@]}"; do
patch_file="vim-${patch_file}.patch"
if [[ ! -f "${NEOVIM_SOURCE_DIR}/${patch_file}" ]]; then
continue
@@ -241,18 +275,24 @@ list_vim_patches() {
printf "\nVim patches missing from Neovim:\n"
# Get commits since 7.4.602.
- local vim_commits=$(cd "${VIM_SOURCE_DIR}" && git log --reverse --format='%H' v7.4.602..HEAD)
+ local vim_commits
+ vim_commits="$(cd "${VIM_SOURCE_DIR}" && git log --reverse --format='%H' v7.4.602..HEAD)"
local vim_commit
for vim_commit in ${vim_commits}; do
local is_missing
- local vim_tag=$(cd "${VIM_SOURCE_DIR}" && git describe --tags --exact-match "${vim_commit}" 2>/dev/null)
+ 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."
# Tagged Vim patch, check version.c:
is_missing="$(sed -n '/static int included_patches/,/}/p' "${NEOVIM_SOURCE_DIR}/src/nvim/version.c" |
grep -x -e "[[:space:]]*//[[:space:]]${patch_number} NA.*" -e "[[:space:]]*${patch_number}," >/dev/null && echo "false" || echo "true")"
vim_commit="${vim_tag#v}"
+ if (cd "${VIM_SOURCE_DIR}" && git show --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 "${NEOVIM_SOURCE_DIR}" &&
@@ -283,8 +323,10 @@ review_commit() {
local neovim_patch_url="${neovim_commit_url}.patch"
local git_patch_prefix='Subject: \[PATCH\] '
- local neovim_patch="$(curl -Ssf "${neovim_patch_url}")"
- local vim_version="$(head -n 4 <<< "${neovim_patch}" | sed -n "s/${git_patch_prefix}vim-patch:\([a-z0-9.]*\)$/\1/p")"
+ local neovim_patch
+ neovim_patch="$(curl -Ssf "${neovim_patch_url}")"
+ local vim_version
+ vim_version="$(head -n 4 <<< "${neovim_patch}" | sed -n "s/${git_patch_prefix}vim-patch:\([a-z0-9.]*\)$/\1/p")"
echo
if [[ -n "${vim_version}" ]]; then
@@ -300,9 +342,12 @@ review_commit() {
local vim_patch_url="${vim_commit_url}.patch"
- local expected_commit_message="$(commit_message)"
- local message_length="$(wc -l <<< "${expected_commit_message}")"
- local commit_message="$(tail -n +4 <<< "${neovim_patch}" | head -n "${message_length}")"
+ local expected_commit_message
+ expected_commit_message="$(commit_message)"
+ local message_length
+ message_length="$(wc -l <<< "${expected_commit_message}")"
+ local commit_message
+ commit_message="$(tail -n +4 <<< "${neovim_patch}" | head -n "${message_length}")"
if [[ "${commit_message#${git_patch_prefix}}" == "${expected_commit_message}" ]]; then
echo "✔ Found expected commit message."
else
@@ -330,9 +375,9 @@ review_commit() {
}
review_pr() {
- check_executable curl
- check_executable nvim
- check_executable jq
+ require_executable curl
+ require_executable nvim
+ require_executable jq
get_vim_sources
@@ -347,7 +392,7 @@ review_pr() {
local pr_commit_url
local reply
- for pr_commit_url in ${pr_commit_urls[@]}; do
+ for pr_commit_url in "${pr_commit_urls[@]}"; do
review_commit "${pr_commit_url}"
if [[ "${pr_commit_url}" != "${pr_commit_urls[-1]}" ]]; then
read -p "Continue with next commit (Y/n)? " -n 1 -r reply