From 5bd8827431b44b023ae858d903eb543f22cafbdd Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 4 Dec 2017 09:08:07 +0100 Subject: vim-patch.sh: always use git log, not version.c --- scripts/vim-patch.sh | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'scripts/vim-patch.sh') diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 2875e7d95a..5c24ede13f 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -327,6 +327,11 @@ list_vim_patches() { local vim_commits vim_commits="$(cd "${VIM_SOURCE_DIR}" && git log --reverse --format='%H' v8.0.0000..HEAD)" + # Find all "vim-patch:xxx" tokens in the Nvim git log. + local tokens + tokens="$(cd "${NVIM_SOURCE_DIR}" && git log -E --grep='vim-patch:[^ ]+' | grep 'vim-patch')" + tokens="$(for i in $tokens ; do echo "$i" | grep -E 'vim-patch:[^ ]{7}' | sed 's/.*\(vim-patch:[.0-9a-z]\+\).*/\1/' ; done)" + local vim_commit for vim_commit in ${vim_commits}; do local is_missing @@ -334,22 +339,21 @@ list_vim_patches() { # 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." - patch_number="$(echo ${patch_number} | sed 's/^0*//g')" # Remove prefix "0" - # Tagged Vim patch, check version.c: - is_missing="$(sed -n '/static const int included_patches/,/}/p' "${NVIM_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 version number (not commit hash). + local patch_number="${vim_tag:1}" # "v7.4.0001" => "7.4.0001" + is_missing="$(echo "$tokens" | >/dev/null 2>&1 grep "vim\-patch:${patch_number}" && echo false || echo true)" vim_commit="${vim_tag#v}" - if (cd "${VIM_SOURCE_DIR}" && git --no-pager show --color=never --name-only "v${vim_commit}" 2>/dev/null) | grep -q ^runtime; then - vim_commit="${vim_commit} (+runtime)" + if ! [ "$is_missing" = "false" ] ; then + if (cd "${VIM_SOURCE_DIR}" && git --no-pager show --color=never --name-only "v${vim_commit}" 2>/dev/null) | grep -q ^runtime; then + vim_commit="${vim_commit} (+runtime)" + fi fi else - # Untagged Vim patch (e.g. runtime updates), check the Neovim git log: - is_missing="$(cd "${NVIM_SOURCE_DIR}" && - git log -1 --no-merges --grep="vim\-patch:${vim_commit:0:7}" --pretty=format:false)" + # Untagged Vim patch (e.g. runtime updates). + is_missing="$(echo "$tokens" | >/dev/null 2>&1 grep "vim\-patch:${vim_commit:0:7}" && echo false || echo true)" fi - if [[ ${is_missing} != "false" ]]; then + if ! [ "$is_missing" = "false" ]; then echo " • ${vim_commit}" fi done -- cgit From 56b49955b70aa803f9fb42e48a147f1881ecb33c Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 11 Dec 2017 00:49:44 +0100 Subject: vim-patch.sh: introduce `-L` --- scripts/vim-patch.sh | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'scripts/vim-patch.sh') diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 5c24ede13f..bac5657cc6 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -21,7 +21,8 @@ usage() { echo echo "Options:" echo " -h Show this message and exit." - echo " -l Show list of Vim patches missing from Neovim." + echo " -l Show list of missing Vim patches." + echo " -L Print missing Vim patches in machine-readable form." echo " -p {vim-revision} Download and generate the specified Vim patch." echo " vim-revision can be a version number '8.0.xxx'" echo " or a valid Git ref (hash, tag, etc.)." @@ -318,11 +319,8 @@ submit_pr() { done } +# Prints a newline-delimited list of Vim commits, for use by scripts. list_vim_patches() { - get_vim_sources - - printf "\nVim patches missing from Neovim:\n" - # Get missing Vim commits local vim_commits vim_commits="$(cd "${VIM_SOURCE_DIR}" && git log --reverse --format='%H' v8.0.0000..HEAD)" @@ -343,18 +341,27 @@ list_vim_patches() { local patch_number="${vim_tag:1}" # "v7.4.0001" => "7.4.0001" is_missing="$(echo "$tokens" | >/dev/null 2>&1 grep "vim\-patch:${patch_number}" && echo false || echo true)" vim_commit="${vim_tag#v}" - if ! [ "$is_missing" = "false" ] ; then - if (cd "${VIM_SOURCE_DIR}" && git --no-pager show --color=never --name-only "v${vim_commit}" 2>/dev/null) | grep -q ^runtime; then - vim_commit="${vim_commit} (+runtime)" - fi - fi else # Untagged Vim patch (e.g. runtime updates). is_missing="$(echo "$tokens" | >/dev/null 2>&1 grep "vim\-patch:${vim_commit:0:7}" && echo false || echo true)" fi if ! [ "$is_missing" = "false" ]; then - echo " • ${vim_commit}" + echo "${vim_commit}" + fi + done +} + +# Prints a human-formatted list of Vim commits, with instructional messages. +show_vim_patches() { + get_vim_sources + printf "\nVim patches missing from Neovim:\n" + + list_vim_patches | while read vim_commit; do + if (cd "${VIM_SOURCE_DIR}" && git --no-pager show --color=never --name-only "v${vim_commit}" 2>/dev/null) | grep -q ^runtime; then + printf " • ${vim_commit} (+runtime)\n" + else + printf " • ${vim_commit}\n" fi done @@ -465,13 +472,17 @@ review_pr() { clean_files } -while getopts "hlp:P:g:r:s" opt; do +while getopts "hlLp:P:g:r:s" opt; do case ${opt} in h) usage exit 0 ;; l) + show_vim_patches + exit 0 + ;; + L) list_vim_patches exit 0 ;; -- cgit From 23fb833ea75107a3349dfb0be2eeccc06111399c Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 11 Dec 2017 00:54:25 +0100 Subject: vim-patch.sh: remove version.c in generated patch Vim patch tracking is now driven completely by `vim-patch:xxx` tokens in the VCS logs. version.c will be auto-generated, if it is used at all. --- scripts/vim-patch.sh | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'scripts/vim-patch.sh') diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index bac5657cc6..04bc16dd25 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -148,6 +148,10 @@ preprocess_patch() { 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" + # Remove version.c #7555 + local na_po='version.c' + 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/\<\%('${na_po}'\)\>@norm! d/\v(^diff)|%$ ' +w +q "$file" + # Remove some *.po files. #5622 local na_po='sjiscorr.c\|ja.sjis.po\|ko.po\|pl.cp1250.po\|pl.po\|ru.cp1251.po\|uk.cp1251.po\|zh_CN.cp936.po\|zh_CN.po\|zh_TW.po' 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/po/\<\%('${na_po}'\)\>@norm! d/\v(^diff)|%$ ' +w +q "$file" -- cgit From 067bb1e9f41319fbe695ba6c0209621addca5b7f Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sat, 16 Dec 2017 21:42:08 -0500 Subject: vim-patch.sh: Include upstream summary in commit message [ci skip] --- scripts/vim-patch.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'scripts/vim-patch.sh') diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 04bc16dd25..530701e223 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -92,8 +92,11 @@ get_vim_sources() { } commit_message() { - printf 'vim-patch:%s\n\n%s\n\n%s' "${vim_version}" \ - "${vim_message}" "${vim_commit_url}" + if [[ -n "$vim_tag" ]]; then + printf '%s\n\n%s' "${vim_message}" "${vim_commit_url}" + else + printf 'vim-patch:%s\n\n%s\n\n%s' "$vim_version" "$vim_message" "$vim_commit_url" + fi } find_git_remote() { @@ -108,22 +111,23 @@ assign_commit_details() { vim_tag="v${1}" vim_commit=$(cd "${VIM_SOURCE_DIR}" \ && git log -1 --format="%H" "${vim_tag}") - local strip_commit_line=true + local munge_commit_line=true else # Interpret parameter as commit hash. vim_version="${1:0:12}" + vim_tag= vim_commit=$(cd "${VIM_SOURCE_DIR}" \ && git log -1 --format="%H" "${vim_version}") - local strip_commit_line=false + local munge_commit_line=false fi vim_commit_url="https://github.com/vim/vim/commit/${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 + if [[ ${munge_commit_line} == "true" ]]; then # Remove first line of commit message. - vim_message="$(echo "${vim_message}" | sed -e '1d')" + vim_message="$(echo "${vim_message}" | sed -e '1s/^patch /vim-patch:/')" fi patch_file="vim-${vim_version}.patch" } @@ -286,9 +290,10 @@ submit_pr() { 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)" + pr_body="$(git log --grep=vim-patch --reverse --format='#### %s%n%n%b%n' "${git_remote}"/master..HEAD)" local patches - patches=("$(git log --reverse --format='%s' "${git_remote}"/master..HEAD)") + # Extract just the "vim-patch:X.Y.ZZZZ" or "vim-patch:sha" portion of each log + patches=("$(git log --grep=vim-patch --reverse --format='%s' "${git_remote}"/master..HEAD | sed 's/: .*//')") 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. -- cgit From 973bd10a127f468b55c79e57f8d7215f9b6e6073 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 11 Dec 2017 01:58:55 +0100 Subject: vim-patch.sh: introduce `-V` --- scripts/vim-patch.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'scripts/vim-patch.sh') diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 530701e223..55a4acc830 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -32,9 +32,10 @@ usage() { 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 ' -V Clones the Vim source code to $VIM_SOURCE_DIR.' echo - echo "Set VIM_SOURCE_DIR to change where Vim's sources are stored." - echo "Default is '${VIM_SOURCE_DIR_DEFAULT}'." + echo ' $VIM_SOURCE_DIR controls where Vim sources are found' + echo " (default: '${VIM_SOURCE_DIR_DEFAULT}')" } # Checks if a program is in the user's PATH, and is executable. @@ -481,7 +482,7 @@ review_pr() { clean_files } -while getopts "hlLp:P:g:r:s" opt; do +while getopts "hlLVp:P:g:r:s" opt; do case ${opt} in h) usage @@ -515,6 +516,10 @@ while getopts "hlLp:P:g:r:s" opt; do submit_pr exit 0 ;; + V) + get_vim_sources + exit 0 + ;; *) exit 1 ;; -- cgit From 903ed09a61b15a63c4909d4fad7b098fa2368d1d Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 16 Dec 2017 21:38:53 +0100 Subject: vim-patch.sh: extract list_vimpatch_tokens() Use streams instead of for-loop (20x speedup for list_vimpatch_tokens). --- scripts/vim-patch.sh | 62 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 25 deletions(-) (limited to 'scripts/vim-patch.sh') diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 55a4acc830..b82d21b03e 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -174,7 +174,7 @@ preprocess_patch() { "$file" > "$file".tmp && mv "$file".tmp "$file" } -get_vim_patch() { +get_vimpatch() { get_vim_sources assign_commit_details "${1}" @@ -200,7 +200,7 @@ get_vim_patch() { } stage_patch() { - get_vim_patch "$1" + get_vimpatch "$1" local try_apply="${2:-}" local git_remote @@ -329,31 +329,43 @@ submit_pr() { done } -# Prints a newline-delimited list of Vim commits, for use by scripts. -list_vim_patches() { - # Get missing Vim commits - local vim_commits - vim_commits="$(cd "${VIM_SOURCE_DIR}" && git log --reverse --format='%H' v8.0.0000..HEAD)" +# Gets all Vim commits since the "start" commit. +list_vim_commits() { ( + cd "${VIM_SOURCE_DIR}" && git log --reverse --format='%H' v8.0.0000..HEAD +) } - # Find all "vim-patch:xxx" tokens in the Nvim git log. +# Prints all "vim-patch:xxx" tokens found in the Nvim git log. +list_vimpatch_tokens() { local tokens + # Find all "vim-patch:xxx" tokens in the Nvim git log. tokens="$(cd "${NVIM_SOURCE_DIR}" && git log -E --grep='vim-patch:[^ ]+' | grep 'vim-patch')" - tokens="$(for i in $tokens ; do echo "$i" | grep -E 'vim-patch:[^ ]{7}' | sed 's/.*\(vim-patch:[.0-9a-z]\+\).*/\1/' ; done)" + echo "$tokens" | grep -E 'vim-patch:[^ ,{]{7,}' \ + | sed 's/.*\(vim-patch:[.0-9a-z]\+\).*/\1/' \ + | sort \ + | uniq +} + +# Prints a newline-delimited list of Vim commits, for use by scripts. +list_missing_vimpatches() { + local tokens vim_commit vim_commits is_missing vim_tag patch_number + + # Find all "vim-patch:xxx" tokens in the Nvim git log. + tokens="$(list_vimpatch_tokens)" - local vim_commit + # Get missing Vim commits + vim_commits="$(list_vim_commits)" for vim_commit in ${vim_commits}; do - local is_missing - 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 + # Check for vim-patch: (usually runtime updates). + is_missing="$(echo "$tokens" | >/dev/null 2>&1 grep "vim\-patch:${vim_commit:0:7}" && echo false || echo true)" + + if ! [ "$is_missing" = "false" ] \ + && vim_tag="$(cd "${VIM_SOURCE_DIR}" && git describe --tags --exact-match "${vim_commit}" 2>/dev/null)" + then # Vim version number (not commit hash). - local patch_number="${vim_tag:1}" # "v7.4.0001" => "7.4.0001" + # Check for vim-patch: (not commit hash). + patch_number="${vim_tag:1}" # "v7.4.0001" => "7.4.0001" is_missing="$(echo "$tokens" | >/dev/null 2>&1 grep "vim\-patch:${patch_number}" && echo false || echo true)" vim_commit="${vim_tag#v}" - else - # Untagged Vim patch (e.g. runtime updates). - is_missing="$(echo "$tokens" | >/dev/null 2>&1 grep "vim\-patch:${vim_commit:0:7}" && echo false || echo true)" fi if ! [ "$is_missing" = "false" ]; then @@ -363,11 +375,11 @@ list_vim_patches() { } # Prints a human-formatted list of Vim commits, with instructional messages. -show_vim_patches() { +show_vimpatches() { get_vim_sources printf "\nVim patches missing from Neovim:\n" - list_vim_patches | while read vim_commit; do + list_missing_vimpatches | while read vim_commit; do if (cd "${VIM_SOURCE_DIR}" && git --no-pager show --color=never --name-only "v${vim_commit}" 2>/dev/null) | grep -q ^runtime; then printf " • ${vim_commit} (+runtime)\n" else @@ -441,7 +453,7 @@ review_commit() { echo "✔ Saved pull request diff to '${NVIM_SOURCE_DIR}/n${patch_file}'." CREATED_FILES+=("${NVIM_SOURCE_DIR}/n${patch_file}") - get_vim_patch "${vim_version}" + get_vimpatch "${vim_version}" CREATED_FILES+=("${NVIM_SOURCE_DIR}/${patch_file}") echo @@ -489,11 +501,11 @@ while getopts "hlLVp:P:g:r:s" opt; do exit 0 ;; l) - show_vim_patches + show_vimpatches exit 0 ;; L) - list_vim_patches + list_missing_vimpatches exit 0 ;; p) @@ -505,7 +517,7 @@ while getopts "hlLVp:P:g:r:s" opt; do exit 0 ;; g) - get_vim_patch "${OPTARG}" + get_vimpatch "${OPTARG}" exit 0 ;; r) -- cgit From 7773bbd0989d798b29486a669775a81cd4ec6d3b Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 26 Dec 2017 03:38:42 +0100 Subject: vimpatch.lua: automate version.c Invoke it like this: VIM_SOURCE_DIR=~/neovim/.vim-src/ nvim -i NONE -u NONE --headless +'luafile ./scripts/vimpatch.lua' +q --- scripts/vim-patch.sh | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) (limited to 'scripts/vim-patch.sh') diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index b82d21b03e..c6ff280bb5 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -14,25 +14,23 @@ readonly BRANCH_PREFIX="vim-" CREATED_FILES=() usage() { - echo "Helper script for porting Vim patches. For more information, see" + echo "Port Vim patches to Neovim" echo "https://github.com/neovim/neovim/wiki/Merging-patches-from-upstream-vim" echo echo "Usage: ${BASENAME} [-h | -l | -p vim-revision | -r pr-number]" echo echo "Options:" echo " -h Show this message and exit." - echo " -l Show list of missing Vim patches." - echo " -L Print missing Vim patches in machine-readable form." - echo " -p {vim-revision} Download and generate the specified Vim patch." - echo " vim-revision can be a version number '8.0.xxx'" - echo " or a valid Git ref (hash, tag, etc.)." - echo " -P {vim-revision} Download, generate and apply the Vim patch." - 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 " -r {pr-number} Review a vim-patch pull request to Neovim." - echo ' -V Clones the Vim source code to $VIM_SOURCE_DIR.' + echo " -l List missing Vim patches." + echo " -L List missing Vim patches (for scripts)." + echo " -M List all merged patch-numbers (at current v:version)." + echo " -p {vim-revision} Download and generate a Vim patch. vim-revision" + echo " can be a Vim version (8.0.xxx) or a Git hash." + echo " -P {vim-revision} Download, generate and apply a Vim patch." + echo " -g {vim-revision} Download a Vim patch." + echo " -s Create a vim-patch pull request." + echo " -r {pr-number} Review a vim-patch pull request." + echo ' -V Clone the Vim source code to $VIM_SOURCE_DIR.' echo echo ' $VIM_SOURCE_DIR controls where Vim sources are found' echo " (default: '${VIM_SOURCE_DIR_DEFAULT}')" @@ -334,7 +332,7 @@ list_vim_commits() { ( cd "${VIM_SOURCE_DIR}" && git log --reverse --format='%H' v8.0.0000..HEAD ) } -# Prints all "vim-patch:xxx" tokens found in the Nvim git log. +# Prints all (sorted) "vim-patch:xxx" tokens found in the Nvim git log. list_vimpatch_tokens() { local tokens # Find all "vim-patch:xxx" tokens in the Nvim git log. @@ -345,6 +343,15 @@ list_vimpatch_tokens() { | uniq } +# Prints all patch-numbers (for the current v:version) for which there is +# a "vim-patch:xxx" token in the Nvim git log. +list_vimpatch_numbers() { + # Transform "vim-patch:X.Y.ZZZZ" to "ZZZZ". + list_vimpatch_tokens | while read vimpatch_token; do + echo "$vimpatch_token" | grep '8\.0\.' | sed 's/.*vim-patch:8\.0\.\([0-9a-z]\+\).*/\1/' + done +} + # Prints a newline-delimited list of Vim commits, for use by scripts. list_missing_vimpatches() { local tokens vim_commit vim_commits is_missing vim_tag patch_number @@ -494,7 +501,7 @@ review_pr() { clean_files } -while getopts "hlLVp:P:g:r:s" opt; do +while getopts "hlLMVp:P:g:r:s" opt; do case ${opt} in h) usage @@ -508,6 +515,10 @@ while getopts "hlLVp:P:g:r:s" opt; do list_missing_vimpatches exit 0 ;; + M) + list_vimpatch_numbers + exit 0 + ;; p) stage_patch "${OPTARG}" exit 0 -- cgit From 0d548b73efb31452465dab5d15238e336125042c Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 30 Dec 2017 14:15:51 +0100 Subject: scripts/vim-patch.sh: continue when patching with -P fails (#7790) The `set -e` caused the script to stop in case `patch` fails, but it is better to continue giving instructions. --- scripts/vim-patch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/vim-patch.sh') diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index c6ff280bb5..ac5e326e9d 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -234,7 +234,7 @@ stage_patch() { printf "\n✘ 'patch' command not found\n" else printf "\nApplying patch...\n" - patch -p1 --posix < "${patch_file}" + patch -p1 --posix < "${patch_file}" || true fi printf "\nInstructions:\n Proceed to port the patch.\n" else -- cgit From e69a71427cd7ebfe9fd86ced65f87521878e409f Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 2 Feb 2018 01:33:34 +0100 Subject: vim-patch.sh: remove --posix from patch invocation This was supposed to avoid creating *.orig. It doesn't do that, and worse, it also seems to prevent new files from being created. --- scripts/vim-patch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/vim-patch.sh') diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index ac5e326e9d..90a731710a 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -234,7 +234,7 @@ stage_patch() { printf "\n✘ 'patch' command not found\n" else printf "\nApplying patch...\n" - patch -p1 --posix < "${patch_file}" || true + patch -p1 < "${patch_file}" || true fi printf "\nInstructions:\n Proceed to port the patch.\n" else -- cgit From b67ce84c453e5db5dd28fdb55efde89b07ecad40 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 2 Feb 2018 21:56:22 +0100 Subject: vim-patch.sh: delete *.orig files --- scripts/vim-patch.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts/vim-patch.sh') diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 90a731710a..c7a23abe5e 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -235,6 +235,7 @@ stage_patch() { else printf "\nApplying patch...\n" patch -p1 < "${patch_file}" || true + find -name '*.orig' -type f -delete fi printf "\nInstructions:\n Proceed to port the patch.\n" else -- cgit From d53aa0e94f87beb9997dd95f77ca277ecd804ba7 Mon Sep 17 00:00:00 2001 From: Giuseppe Date: Thu, 8 Mar 2018 12:58:16 +0100 Subject: vim-patch.sh: more colorful #8115 --- scripts/vim-patch.sh | 63 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 27 deletions(-) (limited to 'scripts/vim-patch.sh') diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index c7a23abe5e..21f11fbf1c 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -36,6 +36,14 @@ usage() { echo " (default: '${VIM_SOURCE_DIR_DEFAULT}')" } +msg_ok() { + printf "\e[32m✔\e[0m $@\n" +} + +msg_err() { + printf "\e[31m✘\e[0m $@\n" +} + # Checks if a program is in the user's PATH, and is executable. check_executable() { test -x "$(command -v "${1}")" @@ -73,20 +81,20 @@ get_vim_sources() { require_executable git if [[ ! -d ${VIM_SOURCE_DIR} ]]; then - echo "Cloning Vim sources into '${VIM_SOURCE_DIR}'." + echo "Cloning Vim into: ${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 - echo "✘ ${VIM_SOURCE_DIR} does not appear to be a git repository." + msg_err "${VIM_SOURCE_DIR} does not appear to be a git repository." echo " Please remove it and try again." exit 1 fi cd "${VIM_SOURCE_DIR}" - echo "Updating Vim sources in '${VIM_SOURCE_DIR}'." + echo "Updating Vim sources: ${VIM_SOURCE_DIR}" git pull && - echo "✔ Updated Vim sources." || - echo "✘ Could not update Vim sources; ignoring error." + msg_ok "Updated Vim sources." || + msg_err "Could not update Vim sources; ignoring error." fi } @@ -178,10 +186,10 @@ get_vimpatch() { assign_commit_details "${1}" git log -1 "${vim_commit}" -- >/dev/null 2>&1 || { - >&2 echo "✘ Couldn't find Vim revision '${vim_commit}'." + >&2 msg_err "Couldn't find Vim revision '${vim_commit}'." exit 3 } - echo "✔ Found Vim revision '${vim_commit}'." + msg_ok "Found Vim revision '${vim_commit}'." local patch_content patch_content="$(git --no-pager show --color=never -1 --pretty=medium "${vim_commit}")" @@ -194,7 +202,7 @@ get_vimpatch() { printf "Pre-processing patch...\n" preprocess_patch "${NVIM_SOURCE_DIR}/${patch_file}" - printf "✔ Saved patch to '${NVIM_SOURCE_DIR}/${patch_file}'.\n" + msg_ok "Saved patch to '${NVIM_SOURCE_DIR}/${patch_file}'.\n" } stage_patch() { @@ -207,31 +215,32 @@ stage_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" + msg_ok "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) + msg_ok "${output}" || + (msg_err "${output}"; false) local nvim_branch="${BRANCH_PREFIX}${vim_version}" 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) + msg_ok "${output}" || + (msg_err "${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}"; false) + msg_ok "${output}" || + (msg_err "${output}"; false) if test -n "$try_apply" ; then if ! check_executable patch; then - printf "\n✘ 'patch' command not found\n" + printf "\n" + msg_err "'patch' command not found\n" else printf "\nApplying patch...\n" patch -p1 < "${patch_file}" || true @@ -283,7 +292,7 @@ submit_pr() { 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." + msg_err "Current branch '${checked_out_branch}' doesn't seem to be a vim-patch branch." exit 1 fi @@ -304,16 +313,16 @@ submit_pr() { 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}"; false) + msg_ok "${output}" || + (msg_err "${output}"; false) echo fi echo "Creating pull request." output="$(${submit_fn} "${pr_message}" 2>&1)" && - echo "✔ ${output}" || - (echo "✘ ${output}"; false) + msg_ok "${output}" || + (msg_err "${output}"; false) echo echo "Cleaning up files." @@ -324,7 +333,7 @@ submit_pr() { continue fi rm -- "${NVIM_SOURCE_DIR}/${patch_file}" - echo "✔ Removed '${NVIM_SOURCE_DIR}/${patch_file}'." + msg_ok "Removed '${NVIM_SOURCE_DIR}/${patch_file}'." done } @@ -421,9 +430,9 @@ review_commit() { echo if [[ -n "${vim_version}" ]]; then - echo "✔ Detected Vim patch '${vim_version}'." + msg_ok "Detected Vim patch '${vim_version}'." else - echo "✘ Could not detect the Vim patch number." + msg_err "Could not detect the Vim patch number." echo " This script assumes that the PR contains only commits" echo " with 'vim-patch:XXX' in their title." echo @@ -446,9 +455,9 @@ review_commit() { local commit_message 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." + msg_ok "Found expected commit message." else - echo "✘ Wrong commit message." + msg_err "Wrong commit message." echo " Expected:" echo "${expected_commit_message}" echo " Actual:" @@ -458,7 +467,7 @@ review_commit() { echo echo "Creating files." echo "${nvim_patch}" > "${NVIM_SOURCE_DIR}/n${patch_file}" - echo "✔ Saved pull request diff to '${NVIM_SOURCE_DIR}/n${patch_file}'." + msg_ok "Saved pull request diff to '${NVIM_SOURCE_DIR}/n${patch_file}'." CREATED_FILES+=("${NVIM_SOURCE_DIR}/n${patch_file}") get_vimpatch "${vim_version}" -- cgit From f8d2aef4f20887bb5a407b5a34cd5dc29fc6771c Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 24 Mar 2018 22:42:13 +0100 Subject: vim-patch.sh: remove blank line before URL This "stacks" better in squashed PRs, etc. --- scripts/vim-patch.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts/vim-patch.sh') diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 21f11fbf1c..5182756d83 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -100,9 +100,9 @@ get_vim_sources() { commit_message() { if [[ -n "$vim_tag" ]]; then - printf '%s\n\n%s' "${vim_message}" "${vim_commit_url}" + printf '%s\n%s' "${vim_message}" "${vim_commit_url}" else - printf 'vim-patch:%s\n\n%s\n\n%s' "$vim_version" "$vim_message" "$vim_commit_url" + printf 'vim-patch:%s\n\n%s\n%s' "$vim_version" "$vim_message" "$vim_commit_url" fi } -- cgit