aboutsummaryrefslogtreecommitdiff
path: root/scripts/vim-patch.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/vim-patch.sh')
-rwxr-xr-xscripts/vim-patch.sh74
1 files changed, 35 insertions, 39 deletions
diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh
index 48ea6b7b29..a2750105c3 100755
--- a/scripts/vim-patch.sh
+++ b/scripts/vim-patch.sh
@@ -127,20 +127,20 @@ assign_commit_details() {
# Patch surgery:
preprocess_patch() {
local file="$1"
- local nvim="nvim -u NORC -i NONE "
+ local nvim="nvim -u NORC -i NONE --headless"
# Remove *.proto, Make*, gui_*, some if_*
local na_src='proto\|Make*\|gui_*'
na_src="$na_src"'\|if_lua\|if_mzsch\|if_olepp\|if_ole\|if_perl\|if_py\|if_ruby\|if_tcl\|if_xcmdsrv'
- $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/\S*\<'${na_src}'@norm! d/\v(^diff)|%$ ' +w +q "$file"
+ 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/\S*\<'${na_src}'@norm! d/\v(^diff)|%$ ' +w +q "$file"
# Remove todo.txt, version*.txt, tags
local na_doc='todo\.txt\|version\d\.txt\|tags'
- $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/runtime/doc/'${na_doc}'@norm! d/\v(^diff)|%$ ' +w +q "$file"
+ 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/runtime/doc/'${na_doc}'@norm! d/\v(^diff)|%$ ' +w +q "$file"
# Remove some testdir/Make_*.mak files
local na_src_testdir='Make_amiga.mak\|Make_dos.mak\|Make_ming.mak\|Make_vms.mms'
- $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/testdir/'${na_src_testdir}'@norm! d/\v(^diff)|%$ ' +w +q "$file"
+ 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/testdir/'${na_src_testdir}'@norm! d/\v(^diff)|%$ ' +w +q "$file"
# Rename src/ paths to src/nvim/
LC_ALL=C sed -e 's/\( [ab]\/src\)/\1\/nvim/g' "$file" > "$file".tmp && mv "$file".tmp "$file"
@@ -155,12 +155,11 @@ get_vim_patch() {
>&2 echo "✘ Couldn't find Vim revision '${vim_commit}'."
exit 3
}
- echo
echo "✔ Found Vim revision '${vim_commit}'."
local patch_content
patch_content="$(git --no-pager show --color=never -1 --pretty=medium "${vim_commit}")"
- local neovim_branch="${BRANCH_PREFIX}${vim_version}"
+ local nvim_branch="${BRANCH_PREFIX}${vim_version}"
cd "${NVIM_SOURCE_DIR}"
local git_remote
@@ -172,51 +171,48 @@ get_vim_patch() {
echo "✔ Current branch '${checked_out_branch}' seems to be a vim-patch"
echo " branch; not creating a new branch."
else
- echo
- echo "Fetching '${git_remote}/master'."
+ printf "\nFetching '${git_remote}/master'.\n"
output="$(git fetch "${git_remote}" master 2>&1)" &&
echo "✔ ${output}" ||
(echo "✘ ${output}"; false)
echo
- echo "Creating new branch '${neovim_branch}' based on '${git_remote}/master'."
+ echo "Creating new branch '${nvim_branch}' based on '${git_remote}/master'."
cd "${NVIM_SOURCE_DIR}"
- output="$(git checkout -b "${neovim_branch}" "${git_remote}/master" 2>&1)" &&
+ output="$(git checkout -b "${nvim_branch}" "${git_remote}/master" 2>&1)" &&
echo "✔ ${output}" ||
(echo "✘ ${output}"; false)
fi
- printf 'Creating empty commit with correct commit message.'
+ printf "\nCreating empty commit with correct commit message.\n"
output="$(commit_message | git commit --allow-empty --file 2>&1 -)" &&
echo "✔ ${output}" ||
(echo "✘ ${output}"; false)
- printf 'Creating patch...'
+ printf "Creating patch...\n"
echo "$patch_content" > "${NVIM_SOURCE_DIR}/${patch_file}"
- printf 'Pre-processing patch...'
+ printf "Pre-processing patch...\n"
preprocess_patch "${NVIM_SOURCE_DIR}/${patch_file}"
- echo "✔ Saved patch to '${NVIM_SOURCE_DIR}/${patch_file}'."
+ printf "✔ Saved patch to '${NVIM_SOURCE_DIR}/${patch_file}'.\n"
- printf '\nInstructions:\n'
- echo " Proceed to port the patch."
- echo " You might want to try 'patch -p1 < ${patch_file}' first."
- echo
- echo " If the patch contains a new test, consider porting it to Lua."
- echo " You might want to try 'scripts/legacy2luatest.pl'."
- echo
- echo " Stage your changes ('git add ...') and use 'git commit --amend' to commit."
- echo
- echo " To port additional patches related to ${vim_version} and add them to the current"
- echo " branch, call '${BASENAME} -p' again. Please use this only if it wouldn't make"
- echo " sense to send in each patch individually, as it will increase the size of the"
- echo " pull request and make it harder to review."
- echo
- echo " When you are finished, use '${BASENAME} -s' to submit a pull request."
- echo
- echo " See https://github.com/neovim/neovim/wiki/Merging-patches-from-upstream-vim"
- echo " for more information."
+ printf "\nInstructions:
+ Proceed to port the patch. This may help:
+ patch -p1 < ${patch_file}
+
+ Stage your changes ('git add ...') and use 'git commit --amend' to commit.
+
+ To port additional patches related to ${vim_version} and add them to the
+ current branch, call '${BASENAME} -p' again.
+ * Do this only for _related_ patches (otherwise it increases the
+ size of the pull request, making it harder to review)
+
+ When you're done, try '${BASENAME} -s' to create the pull request.
+
+ See the wiki for more information:
+ * https://github.com/neovim/neovim/wiki/Merging-patches-from-upstream-vim
+ "
}
hub_pr() {
@@ -340,14 +336,14 @@ list_vim_patches() {
}
review_commit() {
- local neovim_commit_url="${1}"
- local neovim_patch_url="${neovim_commit_url}.patch"
+ local nvim_commit_url="${1}"
+ local nvim_patch_url="${nvim_commit_url}.patch"
local git_patch_prefix='Subject: \[PATCH\] '
- local neovim_patch
- neovim_patch="$(curl -Ssf "${neovim_patch_url}")"
+ local nvim_patch
+ nvim_patch="$(curl -Ssf "${nvim_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")"
+ vim_version="$(head -n 4 <<< "${nvim_patch}" | sed -n "s/${git_patch_prefix}vim-patch:\([a-z0-9.]*\)$/\1/p")"
echo
if [[ -n "${vim_version}" ]]; then
@@ -368,7 +364,7 @@ review_commit() {
local message_length
message_length="$(wc -l <<< "${expected_commit_message}")"
local commit_message
- commit_message="$(tail -n +4 <<< "${neovim_patch}" | head -n "${message_length}")"
+ 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."
else
@@ -381,7 +377,7 @@ review_commit() {
echo
echo "Creating files."
- echo "${neovim_patch}" > "${NVIM_SOURCE_DIR}/n${patch_file}"
+ echo "${nvim_patch}" > "${NVIM_SOURCE_DIR}/n${patch_file}"
echo "✔ Saved pull request diff to '${NVIM_SOURCE_DIR}/n${patch_file}'."
CREATED_FILES+=("${NVIM_SOURCE_DIR}/n${patch_file}")