vim-patch: Add -g switch to download/preprocess patch

This commit is contained in:
James McCoy 2016-12-12 20:48:55 -05:00
parent 988ab5804a
commit c6bd9f525c
No known key found for this signature in database
GPG Key ID: DFE691AE331BA3DB

View File

@ -25,6 +25,9 @@ usage() {
echo " -p {vim-revision} Download and apply the Vim patch vim-revision." echo " -p {vim-revision} Download and apply the Vim patch vim-revision."
echo " vim-revision can be a version number of the " echo " vim-revision can be a version number of the "
echo " format '7.4.xxx' or a Git commit hash." echo " format '7.4.xxx' or a Git commit hash."
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 " -s Submit a vim-patch pull request to Neovim."
echo " -r {pr-number} Review a vim-patch pull request to Neovim." echo " -r {pr-number} Review a vim-patch pull request to Neovim."
echo echo
@ -166,9 +169,21 @@ get_vim_patch() {
local patch_content local patch_content
patch_content="$(git --no-pager show --color=never -1 --pretty=medium "${vim_commit}")" patch_content="$(git --no-pager show --color=never -1 --pretty=medium "${vim_commit}")"
local nvim_branch="${BRANCH_PREFIX}${vim_version}"
cd "${NVIM_SOURCE_DIR}" cd "${NVIM_SOURCE_DIR}"
printf "Creating patch...\n"
echo "$patch_content" > "${NVIM_SOURCE_DIR}/${patch_file}"
printf "Pre-processing patch...\n"
preprocess_patch "${NVIM_SOURCE_DIR}/${patch_file}"
printf "✔ Saved patch to '${NVIM_SOURCE_DIR}/${patch_file}'.\n"
}
stage_patch() {
get_vim_patch "$1"
local git_remote local git_remote
git_remote="$(find_git_remote)" git_remote="$(find_git_remote)"
local checked_out_branch local checked_out_branch
@ -183,6 +198,7 @@ get_vim_patch() {
echo "${output}" || echo "${output}" ||
(echo "${output}"; false) (echo "${output}"; false)
local nvim_branch="${BRANCH_PREFIX}${vim_version}"
echo echo
echo "Creating new branch '${nvim_branch}' based on '${git_remote}/master'." echo "Creating new branch '${nvim_branch}' based on '${git_remote}/master'."
cd "${NVIM_SOURCE_DIR}" cd "${NVIM_SOURCE_DIR}"
@ -196,14 +212,6 @@ get_vim_patch() {
echo "${output}" || echo "${output}" ||
(echo "${output}"; false) (echo "${output}"; false)
printf "Creating patch...\n"
echo "$patch_content" > "${NVIM_SOURCE_DIR}/${patch_file}"
printf "Pre-processing patch...\n"
preprocess_patch "${NVIM_SOURCE_DIR}/${patch_file}"
printf "✔ Saved patch to '${NVIM_SOURCE_DIR}/${patch_file}'.\n"
printf "\nInstructions: printf "\nInstructions:
Proceed to port the patch. This may help: Proceed to port the patch. This may help:
patch -p1 < ${patch_file} patch -p1 < ${patch_file}
@ -218,8 +226,7 @@ get_vim_patch() {
When you're done, try '${BASENAME} -s' to create the pull request. When you're done, try '${BASENAME} -s' to create the pull request.
See the wiki for more information: See the wiki for more information:
* https://github.com/neovim/neovim/wiki/Merging-patches-from-upstream-vim * https://github.com/neovim/neovim/wiki/Merging-patches-from-upstream-vim\n"
"
} }
hub_pr() { hub_pr() {
@ -430,7 +437,7 @@ review_pr() {
clean_files clean_files
} }
while getopts "hlp:r:s" opt; do while getopts "hlp:g:r:s" opt; do
case ${opt} in case ${opt} in
h) h)
usage usage
@ -441,6 +448,10 @@ while getopts "hlp:r:s" opt; do
exit 0 exit 0
;; ;;
p) p)
stage_patch "${OPTARG}"
exit 0
;;
g)
get_vim_patch "${OPTARG}" get_vim_patch "${OPTARG}"
exit 0 exit 0
;; ;;