diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/gendeclarations.lua | 2 | ||||
-rw-r--r-- | scripts/genoptions.lua | 1 | ||||
-rwxr-xr-x | scripts/git-log-pretty-since.sh | 32 | ||||
-rwxr-xr-x | scripts/legacy2luatest.pl | 2 | ||||
-rw-r--r-- | scripts/msgpack-gen.lua | 15 | ||||
-rwxr-xr-x | scripts/release.sh | 63 | ||||
-rwxr-xr-x | scripts/vim-patch.sh | 304 |
7 files changed, 338 insertions, 81 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/genoptions.lua b/scripts/genoptions.lua index 2859ca1795..da53d010bd 100644 --- a/scripts/genoptions.lua +++ b/scripts/genoptions.lua @@ -39,6 +39,7 @@ local redraw_flags={ local list_flags={ comma='P_COMMA', + onecomma='P_ONECOMMA', flags='P_FLAGLIST', flagscomma='P_COMMA|P_FLAGLIST', } diff --git a/scripts/git-log-pretty-since.sh b/scripts/git-log-pretty-since.sh new file mode 100755 index 0000000000..d8e3282fb3 --- /dev/null +++ b/scripts/git-log-pretty-since.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +# Shows a log with changes grouped next to their merge-commit. +# +# Parameters: +# $1 "since" commit +# $2 "inverse match" regex pattern + +set -e +set -u +set -o pipefail + +__SINCE=$1 +__INVMATCH=$2 + +is_merge_commit() { + git rev-parse $1 >/dev/null 2>&1 \ + || { echo "ERROR: invalid commit: $1"; exit 1; } + git log $1^2 >/dev/null 2>&1 && return 0 || return 1 +} + +for commit in $(git log --format='%H' --first-parent --since $__SINCE); do + if is_merge_commit ${commit} ; then + if [ -z "$__INVMATCH" ] || ! git log --oneline ${commit}^1..${commit}^2 \ + | grep -E "$__INVMATCH" >/dev/null 2>&1 ; then + git log -1 --oneline ${commit} + git log --format=' %h %s' ${commit}^1..${commit}^2 + fi + else + git log -1 --oneline ${commit} + fi +done diff --git a/scripts/legacy2luatest.pl b/scripts/legacy2luatest.pl index ebd8dad1e1..8155353fc7 100755 --- a/scripts/legacy2luatest.pl +++ b/scripts/legacy2luatest.pl @@ -287,7 +287,7 @@ local feed, insert, source = helpers.feed, helpers.insert, helpers.source local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect describe('$test_name', function() - setup(clear) + before_each(clear) it('is working', function() @{[join "\n", map { /^$/ ? '' : ' ' . $_ } @{$test_body_lines}]} diff --git a/scripts/msgpack-gen.lua b/scripts/msgpack-gen.lua index d50ebd85a2..190af636dc 100644 --- a/scripts/msgpack-gen.lua +++ b/scripts/msgpack-gen.lua @@ -1,5 +1,5 @@ lpeg = require('lpeg') -msgpack = require('MessagePack') +mpack = require('mpack') -- lpeg grammar for building api metadata from a set of header files. It -- ignores comments and preprocessor commands and parses a very small subset @@ -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 @@ -115,7 +120,7 @@ static const uint8_t msgpack_metadata[] = { ]]) -- serialize the API metadata using msgpack and embed into the resulting -- binary for easy querying by clients -packed = msgpack.pack(functions) +packed = mpack.pack(functions) for i = 1, #packed do output:write(string.byte(packed, i)..', ') if i % 10 == 0 then @@ -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 new file mode 100755 index 0000000000..67738ccc96 --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,63 @@ +#!/bin/sh + +# Performs steps to tag a release. +# +# Steps: +# Create the "release" commit: +# - CMakeLists.txt: Unset NVIM_VERSION_PRERELEASE +# - Tag the commit. +# Create the "version bump" commit: +# - CMakeLists.txt: Set NVIM_VERSION_PRERELEASE to "-dev" +# +# Manual steps: +# - CMakeLists.txt: Bump NVIM_VERSION_* as appropriate. +# - git push --follow-tags + +set -e +set -u +set -o pipefail + +cd "$(git rev-parse --show-toplevel)" + +__LAST_TAG=$(git describe --abbrev=0) +[ -z "$__LAST_TAG" ] && { echo 'ERROR: no tag found'; exit 1; } +__VERSION_MAJOR=$(grep 'set(NVIM_VERSION_MAJOR' CMakeLists.txt\ + |sed -r 's/.*NVIM_VERSION_MAJOR ([[:digit:]]).*/\1/') +__VERSION_MINOR=$(grep 'set(NVIM_VERSION_MINOR' CMakeLists.txt\ + |sed -r 's/.*NVIM_VERSION_MINOR ([[:digit:]]).*/\1/') +__VERSION_PATCH=$(grep 'set(NVIM_VERSION_PATCH' CMakeLists.txt\ + |sed -r 's/.*NVIM_VERSION_PATCH ([[:digit:]]).*/\1/') +__VERSION="${__VERSION_MAJOR}.${__VERSION_MINOR}.${__VERSION_PATCH}" +{ [ -z "$__VERSION_MAJOR" ] || [ -z "$__VERSION_MINOR" ] || [ -z "$__VERSION_PATCH" ]; } \ + && { echo "ERROR: version parse failed: '${__VERSION}'"; exit 1; } +__RELEASE_MSG="NVIM v${__VERSION} + +Features: + +Fixes: + +Changes: + +" +__BUMP_MSG="version bump" + +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')" + +git add CMakeLists.txt +git commit --edit -m "${__RELEASE_MSG} ${__CHANGELOG}" +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 +git add CMakeLists.txt +git commit -m "$__BUMP_MSG" + +echo " +Next steps: + - Double-check NVIM_VERSION_* in CMakeLists.txt + - git push --follow-tags + - update website: index.html" diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index bdd3d6209b..62f2b80a82 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -5,9 +5,12 @@ set -u set -o pipefail readonly NEOVIM_SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -readonly VIM_SOURCE_DIR_DEFAULT=${NEOVIM_SOURCE_DIR}/.vim-src +readonly VIM_SOURCE_DIR_DEFAULT="${NEOVIM_SOURCE_DIR}/.vim-src" readonly VIM_SOURCE_DIR="${VIM_SOURCE_DIR:-${VIM_SOURCE_DIR_DEFAULT}}" readonly BASENAME="$(basename "${0}")" +readonly BRANCH_PREFIX="vim-" + +CREATED_FILES=() usage() { echo "Helper script for porting Vim patches. For more information, see" @@ -21,6 +24,7 @@ usage() { echo " -p {vim-revision} Download and apply 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 " -r {pr-number} Review a vim-patch pull request to Neovim." echo echo "Set VIM_SOURCE_DIR to change where Vim's sources are stored." @@ -29,18 +33,43 @@ 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 } +clean_files() { + if [[ ${#CREATED_FILES[@]} -eq 0 ]]; then + return + fi + + echo + echo "Created files:" + local file + 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[@]}" + 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}'." - git clone --depth=1000 https://github.com/vim/vim.git "${VIM_SOURCE_DIR}" + git clone https://github.com/vim/vim.git "${VIM_SOURCE_DIR}" cd "${VIM_SOURCE_DIR}" else if [[ ! -d "${VIM_SOURCE_DIR}/.git" ]]; then @@ -61,27 +90,36 @@ commit_message() { "${vim_message}" "${vim_commit_url}" } +find_git_remote() { + git remote -v \ + | awk '$2 ~ /github.com[:/]neovim\/neovim/ && $3 == "(fetch)" {print $1; exit}' +} + assign_commit_details() { if [[ ${1} =~ [0-9]\.[0-9]\.[0-9]{3,4} ]]; then # Interpret parameter as version number (tag). vim_version="${1}" vim_tag="v${1}" - vim_commit=$( cd "${VIM_SOURCE_DIR}" \ - && git log -1 --format="%H" ${vim_tag} ) + vim_commit=$(cd "${VIM_SOURCE_DIR}" \ + && 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="${1}" + vim_commit=$(cd "${VIM_SOURCE_DIR}" \ + && git log -1 --format="%H" "${vim_version}") local strip_commit_line=false fi vim_commit_url="https://github.com/vim/vim/commit/${vim_commit}" - vim_message="$(git log -1 --pretty='format:%B' "${vim_commit}")" + vim_message="$(cd "${VIM_SOURCE_DIR}" \ + && git log -1 --pretty='format:%B' "${vim_commit}" \ + | sed -e 's/\(#[0-9]*\)/vim\/vim\1/g')" if [[ ${strip_commit_line} == "true" ]]; then # Remove first line of commit message. vim_message="$(echo "${vim_message}" | sed -e '1d')" fi + patch_file="vim-${vim_version}.patch" } get_vim_patch() { @@ -96,84 +134,165 @@ get_vim_patch() { echo echo "✔ Found Vim revision '${vim_commit}'." - # Collect patch details and store into variables. - vim_full="$(git show -1 --pretty=medium "${vim_commit}")" # Patch surgery: preprocess the patch. # - transform src/ paths to src/nvim/ - vim_diff="$(git show -1 "${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')" - neovim_message="$(commit_message)" - neovim_pr=" -\`\`\` -${vim_message} -\`\`\` + local neovim_branch="${BRANCH_PREFIX}${vim_version}" -${vim_commit_url} - -Original patch: - -\`\`\`diff -${vim_diff} -\`\`\`" - neovim_branch="vim-${vim_version}" - - echo - echo "Creating Git branch." cd "${NEOVIM_SOURCE_DIR}" - output="$(git checkout -b "${neovim_branch}" 2>&1)" && - echo "✔ ${output}" || - (echo "✘ ${output}"; false) + 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" + echo " branch; not creating a new branch." + else + echo + echo "Fetching '${git_remote}/master'." + 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'." + cd "${NEOVIM_SOURCE_DIR}" + output="$(git checkout -b "${neovim_branch}" "${git_remote}/master" 2>&1)" && + echo "✔ ${output}" || + (echo "✘ ${output}"; false) + fi echo echo "Creating empty commit with correct commit message." - output="$(git commit --allow-empty --file 2>&1 - <<< "${neovim_message}")" && + output="$(commit_message | git commit --allow-empty --file 2>&1 -)" && echo "✔ ${output}" || (echo "✘ ${output}"; false) echo echo "Creating files." - echo "${vim_diff}" > "${NEOVIM_SOURCE_DIR}/${neovim_branch}.diff" - echo "✔ Saved diff to '${NEOVIM_SOURCE_DIR}/${neovim_branch}.diff'." - echo "${vim_full}" > "${NEOVIM_SOURCE_DIR}/${neovim_branch}.patch" - echo "✔ Saved full commit details to '${NEOVIM_SOURCE_DIR}/${neovim_branch}.patch'." - echo "${neovim_pr}" > "${NEOVIM_SOURCE_DIR}/${neovim_branch}.pr" - echo "✔ Saved suggested PR description to '${NEOVIM_SOURCE_DIR}/${neovim_branch}.pr'." - echo "You can use 'git clean' to remove these files when you're done." + echo "${vim_full}" > "${NEOVIM_SOURCE_DIR}/${patch_file}" + echo "✔ Saved full commit details to '${NEOVIM_SOURCE_DIR}/${patch_file}'." echo echo "Instructions:" echo echo " Proceed to port the patch." - echo " You might want to try 'patch -p1 < ${neovim_branch}.diff' first." + 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 " Push your changes with 'git push origin ${neovim_branch}' and create a" - echo " pull request called '[RFC] vim-patch:${vim_version}'. You might want " - echo " to use the text in '${neovim_branch}.pr' as the description of this pull request." + 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." } +hub_pr() { + hub pull-request -m "$1" +} + +git_hub_pr() { + git hub pull new -m "$1" +} + +submit_pr() { + 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 + 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 + 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. + pr_title="${pr_title// /,}" # Replace spaces with commas. + + local pr_message + pr_message="$(printf '[RFC] vim-patch:%s\n\n%s\n' "${pr_title#,}" "${pr_body}")" + + 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 "Creating pull request." + 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 + patch_file="vim-${patch_file}.patch" + if [[ ! -f "${NEOVIM_SOURCE_DIR}/${patch_file}" ]]; then + continue + fi + rm -- "${NEOVIM_SOURCE_DIR}/${patch_file}" + echo "✔ Removed '${NEOVIM_SOURCE_DIR}/${patch_file}'." + done +} + list_vim_patches() { get_vim_sources 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")" + 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}" && @@ -189,7 +308,8 @@ list_vim_patches() { echo "Instructions:" echo echo " To port one of the above patches to Neovim, execute" - echo " this script with the patch revision as argument." + echo " this script with the patch revision as argument and" + echo " follow the instructions." echo echo " Examples: '${BASENAME} -p 7.4.487'" echo " '${BASENAME} -p 1e8ebf870720e7b671f98f22d653009826304c4f'" @@ -198,35 +318,36 @@ list_vim_patches() { echo " Out-of-order patches increase the possibility of bugs." } -review_pr() { - check_executable curl - check_executable nvim - - get_vim_sources - - local pr="${1}" - echo - echo "Downloading data for pull request #${pr}." +review_commit() { + local neovim_commit_url="${1}" + local neovim_patch_url="${neovim_commit_url}.patch" local git_patch_prefix='Subject: \[PATCH\] ' - local neovim_patch="$(curl -Ssf "https://patch-diff.githubusercontent.com/raw/neovim/neovim/pull/${pr}.patch")" - echo "${neovim_patch}" > a - 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 echo "✔ Detected Vim patch '${vim_version}'." else echo "✘ Could not detect the Vim patch number." - echo " This script assumes that the PR contains a single commit" - echo " with 'vim-patch:XXX' as its title." + echo " This script assumes that the PR contains only commits" + echo " with 'vim-patch:XXX' in their title." exit 1 fi assign_commit_details "${vim_version}" - 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 vim_patch_url="${vim_commit_url}.patch" + + 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 @@ -235,26 +356,57 @@ review_pr() { echo "${expected_commit_message}" echo " Actual:" echo "${commit_message#${git_patch_prefix}}" - exit 1 fi - local base_name="vim-${vim_version}" echo echo "Creating files." - curl -Ssfo "${NEOVIM_SOURCE_DIR}/n${base_name}.diff" "https://patch-diff.githubusercontent.com/raw/neovim/neovim/pull/${pr}.diff" - echo "✔ Saved pull request diff to '${NEOVIM_SOURCE_DIR}/n${base_name}.diff'." - echo "${neovim_patch}" > "${NEOVIM_SOURCE_DIR}/n${base_name}.patch" - echo "✔ Saved full pull request commit details to '${NEOVIM_SOURCE_DIR}/n${base_name}.patch'." - git show "${vim_commit}" > "${NEOVIM_SOURCE_DIR}/${base_name}.diff" - echo "✔ Saved Vim diff to '${NEOVIM_SOURCE_DIR}/${base_name}.diff'." - echo "You can use 'git clean' to remove these files when you're done." + echo "${neovim_patch}" > "${NEOVIM_SOURCE_DIR}/n${patch_file}" + echo "✔ Saved pull request diff to '${NEOVIM_SOURCE_DIR}/n${patch_file}'." + CREATED_FILES+=("${NEOVIM_SOURCE_DIR}/n${patch_file}") + + curl -Ssfo "${NEOVIM_SOURCE_DIR}/${patch_file}" "${vim_patch_url}" + echo "✔ Saved Vim diff to '${NEOVIM_SOURCE_DIR}/${patch_file}'." + CREATED_FILES+=("${NEOVIM_SOURCE_DIR}/${patch_file}") echo echo "Launching nvim." - exec nvim -O "${NEOVIM_SOURCE_DIR}/${base_name}.diff" "${NEOVIM_SOURCE_DIR}/n${base_name}.diff" + nvim -c "cd ${NEOVIM_SOURCE_DIR}" \ + -O "${NEOVIM_SOURCE_DIR}/${patch_file}" "${NEOVIM_SOURCE_DIR}/n${patch_file}" +} + +review_pr() { + require_executable curl + require_executable nvim + require_executable jq + + get_vim_sources + + local pr="${1}" + echo + echo "Downloading data for pull request #${pr}." + + local pr_commit_urls=($(curl -Ssf "https://api.github.com/repos/neovim/neovim/pulls/${pr}/commits" \ + | jq -r '.[].html_url')) + + echo "Found ${#pr_commit_urls[@]} commit(s)." + + local pr_commit_url + local reply + 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 + echo + if [[ ! "${reply}" =~ ^[Yy]$ ]]; then + break + fi + fi + done + + clean_files } -while getopts "hlp:r:" opt; do +while getopts "hlp:r:s" opt; do case ${opt} in h) usage @@ -272,6 +424,10 @@ while getopts "hlp:r:" opt; do review_pr "${OPTARG}" exit 0 ;; + s) + submit_pr + exit 0 + ;; *) exit 1 ;; |