vim-patch.sh: Use printf instead of echo

Also: neovim => nvim
This commit is contained in:
Justin M. Keyes
2016-09-13 12:18:07 +02:00
parent d5aaa18316
commit d61826a85c

View File

@@ -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)|%$
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'
local na_doc='todo\.txt\|version\d\.txt\|tags'
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
# Remove some testdir/Make_*.mak files
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"
@@ -155,12 +155,11 @@ get_vim_patch() {
assign_commit_details "${1}"
git log -1 "${vim_commit}" -- >/dev/null 2>&1 || {
>&2 echo "✘ Couldn't find Vim revision '${vim_commit}'."
>&2 echo "✘ Couldn't find Vim revision '${vim_commit}'."
exit 3
}
echo "✔ Found Vim revision '${vim_commit}'."
local patch_content
patch_content="$(git --no-pager show --color=never -1 --pretty=medium "${vim_commit}")"
local nvim_branch="${BRANCH_PREFIX}${vim_version}"
@@ -172,51 +171,48 @@ get_vim_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"
echo " branch; not creating a new branch."
echo "✔ 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)
(echo "${output}"; false)
echo
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)
(echo "${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}" ||
(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 '\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."
printf "✔ Saved patch to '${NVIM_SOURCE_DIR}/${patch_file}'.\n"
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
"
@@ -340,14 +336,14 @@ list_vim_patches() {
echo
echo " NOTE: Please port the _oldest_ patch if you possibly can."
echo " Out-of-order patches increase the possibility of bugs."
}
}
review_commit() {
local nvim_commit_url="${1}"
local neovim_patch_url="${neovim_commit_url}.patch"
local nvim_patch_url="${nvim_commit_url}.patch"
local git_patch_prefix='Subject: \[PATCH\] '
local neovim_patch
local nvim_patch
nvim_patch="$(curl -Ssf "${nvim_patch_url}")"
local vim_version
vim_version="$(head -n 4 <<< "${nvim_patch}" | sed -n "s/${git_patch_prefix}vim-patch:\([a-z0-9.]*\)$/\1/p")"
@@ -368,7 +364,7 @@ review_commit() {
local expected_commit_message
expected_commit_message="$(commit_message)"
local message_length
local message_length
message_length="$(wc -l <<< "${expected_commit_message}")"
local commit_message
commit_message="$(tail -n +4 <<< "${nvim_patch}" | head -n "${message_length}")"
@@ -381,7 +377,7 @@ review_commit() {
echo " Actual:"
echo "${commit_message#${git_patch_prefix}}"
fi
echo
echo "Creating files."
echo "${nvim_patch}" > "${NVIM_SOURCE_DIR}/n${patch_file}"