From af3d4b40492e6eb9f3ab44d819addceb29b01fe0 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 16 May 2016 23:41:41 -0400 Subject: [PATCH 1/3] vim-patch.sh: Rename check_executable to require_executable check_executable now just wraps the "exists && executable" check. This will be needed to allow fallbacks for commands. --- scripts/vim-patch.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 751f50d290..2d9f61ff36 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 @@ -61,7 +65,7 @@ clean_files() { } get_vim_sources() { - check_executable git + require_executable git if [[ ! -d ${VIM_SOURCE_DIR} ]]; then echo "Cloning Vim sources into '${VIM_SOURCE_DIR}'." @@ -195,8 +199,8 @@ get_vim_patch() { } submit_pr() { - check_executable git - check_executable hub + require_executable git + require_executable hub cd "${NEOVIM_SOURCE_DIR}" local checked_out_branch @@ -346,9 +350,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 From 957c91d5d041a8f6d5a9cb5b5a771b1c08d872aa Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 16 May 2016 23:53:56 -0400 Subject: [PATCH 2/3] vim-patch.sh: Add support for sociomatic/git-hub --- scripts/vim-patch.sh | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 2d9f61ff36..8f9c3c36b2 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -198,9 +198,28 @@ 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() { require_executable git - require_executable hub + 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 @@ -223,14 +242,17 @@ submit_pr() { 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) From 8759a77dc2327eb23701ee3902b4cf69c8b70823 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Wed, 18 May 2016 20:37:31 -0400 Subject: [PATCH 3/3] vim-patch.sh: Show if a patch includes runtime files --- scripts/vim-patch.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 8f9c3c36b2..7a0001769a 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -290,6 +290,9 @@ list_vim_patches() { 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}" &&