mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
Merge pull request #4742 from brcolow/shellcheck-lint
Run shellcheck (shell scripting linter) on shell scripts.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env bash
|
#!/bin/sh
|
||||||
|
|
||||||
# Performs steps to tag a release.
|
# Performs steps to tag a release.
|
||||||
#
|
#
|
||||||
@@ -45,11 +45,11 @@ echo "Most recent tag: ${__LAST_TAG}"
|
|||||||
echo "Release version: ${__VERSION}"
|
echo "Release version: ${__VERSION}"
|
||||||
sed -i -r 's/(NVIM_VERSION_PRERELEASE) "-dev"/\1 ""/' CMakeLists.txt
|
sed -i -r 's/(NVIM_VERSION_PRERELEASE) "-dev"/\1 ""/' CMakeLists.txt
|
||||||
echo "Building changelog since ${__LAST_TAG}..."
|
echo "Building changelog since ${__LAST_TAG}..."
|
||||||
__CHANGELOG="$(./scripts/git-log-pretty-since.sh $__LAST_TAG 'vim-patch:\S')"
|
__CHANGELOG="$(./scripts/git-log-pretty-since.sh "$__LAST_TAG" 'vim-patch:\S')"
|
||||||
|
|
||||||
git add CMakeLists.txt
|
git add CMakeLists.txt
|
||||||
git commit --edit -m "${__RELEASE_MSG} ${__CHANGELOG}"
|
git commit --edit -m "${__RELEASE_MSG} ${__CHANGELOG}"
|
||||||
git tag -a v${__VERSION} -m "NVIM v${__VERSION}"
|
git tag -a v"${__VERSION}" -m "NVIM v${__VERSION}"
|
||||||
|
|
||||||
sed -i -r 's/(NVIM_VERSION_PRERELEASE) ""/\1 "-dev"/' CMakeLists.txt
|
sed -i -r 's/(NVIM_VERSION_PRERELEASE) ""/\1 "-dev"/' CMakeLists.txt
|
||||||
nvim -c '/NVIM_VERSION' -c 'echo "Update version numbers"' CMakeLists.txt
|
nvim -c '/NVIM_VERSION' -c 'echo "Update version numbers"' CMakeLists.txt
|
||||||
|
@@ -47,14 +47,14 @@ clean_files() {
|
|||||||
echo
|
echo
|
||||||
echo "Created files:"
|
echo "Created files:"
|
||||||
local file
|
local file
|
||||||
for file in ${CREATED_FILES[@]}; do
|
for file in "${CREATED_FILES[@]}"; do
|
||||||
echo " • ${file}"
|
echo " • ${file}"
|
||||||
done
|
done
|
||||||
|
|
||||||
read -p "Delete these files (Y/n)? " -n 1 -r reply
|
read -p "Delete these files (Y/n)? " -n 1 -r reply
|
||||||
echo
|
echo
|
||||||
if [[ "${reply}" =~ ^[Yy]$ ]]; then
|
if [[ "${reply}" =~ ^[Yy]$ ]]; then
|
||||||
rm -- ${CREATED_FILES[@]}
|
rm -- "${CREATED_FILES[@]}"
|
||||||
else
|
else
|
||||||
echo "You can use 'git clean' to remove these files when you're done."
|
echo "You can use 'git clean' to remove these files when you're done."
|
||||||
fi
|
fi
|
||||||
@@ -97,13 +97,13 @@ assign_commit_details() {
|
|||||||
vim_version="${1}"
|
vim_version="${1}"
|
||||||
vim_tag="v${1}"
|
vim_tag="v${1}"
|
||||||
vim_commit=$(cd "${VIM_SOURCE_DIR}" \
|
vim_commit=$(cd "${VIM_SOURCE_DIR}" \
|
||||||
&& git log -1 --format="%H" ${vim_tag})
|
&& git log -1 --format="%H" "${vim_tag}")
|
||||||
local strip_commit_line=true
|
local strip_commit_line=true
|
||||||
else
|
else
|
||||||
# Interpret parameter as commit hash.
|
# Interpret parameter as commit hash.
|
||||||
vim_version="${1:0:7}"
|
vim_version="${1:0:7}"
|
||||||
vim_commit=$(cd "${VIM_SOURCE_DIR}" \
|
vim_commit=$(cd "${VIM_SOURCE_DIR}" \
|
||||||
&& git log -1 --format="%H" ${vim_version})
|
&& git log -1 --format="%H" "${vim_version}")
|
||||||
local strip_commit_line=false
|
local strip_commit_line=false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -132,13 +132,16 @@ get_vim_patch() {
|
|||||||
|
|
||||||
# Patch surgery: preprocess the patch.
|
# Patch surgery: preprocess the patch.
|
||||||
# - transform src/ paths to src/nvim/
|
# - transform src/ paths to src/nvim/
|
||||||
local vim_full="$(git show -1 --pretty=medium "${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')"
|
| LC_ALL=C sed -e 's/\( [ab]\/src\)/\1\/nvim/g')"
|
||||||
local neovim_branch="${BRANCH_PREFIX}${vim_version}"
|
local neovim_branch="${BRANCH_PREFIX}${vim_version}"
|
||||||
|
|
||||||
cd "${NEOVIM_SOURCE_DIR}"
|
cd "${NEOVIM_SOURCE_DIR}"
|
||||||
local git_remote=$(find_git_remote)
|
local git_remote
|
||||||
local checked_out_branch="$(git rev-parse --abbrev-ref HEAD)"
|
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
|
if [[ "${checked_out_branch}" == ${BRANCH_PREFIX}* ]]; then
|
||||||
echo "✔ Current branch '${checked_out_branch}' seems to be a vim-patch"
|
echo "✔ Current branch '${checked_out_branch}' seems to be a vim-patch"
|
||||||
@@ -196,20 +199,25 @@ submit_pr() {
|
|||||||
check_executable hub
|
check_executable hub
|
||||||
|
|
||||||
cd "${NEOVIM_SOURCE_DIR}"
|
cd "${NEOVIM_SOURCE_DIR}"
|
||||||
local checked_out_branch="$(git rev-parse --abbrev-ref HEAD)"
|
local checked_out_branch
|
||||||
|
checked_out_branch="$(git rev-parse --abbrev-ref HEAD)"
|
||||||
if [[ "${checked_out_branch}" != ${BRANCH_PREFIX}* ]]; then
|
if [[ "${checked_out_branch}" != ${BRANCH_PREFIX}* ]]; then
|
||||||
echo "✘ Current branch '${checked_out_branch}' doesn't seem to be a vim-patch branch."
|
echo "✘ Current branch '${checked_out_branch}' doesn't seem to be a vim-patch branch."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local git_remote=$(find_git_remote)
|
local git_remote
|
||||||
local pr_body="$(git log --reverse --format='#### %s%n%n%b%n' ${git_remote}/master..HEAD)"
|
git_remote="$(find_git_remote)"
|
||||||
local patches=("$(git log --reverse --format='%s' ${git_remote}/master..HEAD)")
|
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.
|
patches=(${patches[@]//vim-patch:}) # Remove 'vim-patch:' prefix for each item in array.
|
||||||
local pr_title="${patches[@]}" # Create space-separated string from array.
|
local pr_title="${patches[*]}" # Create space-separated string from array.
|
||||||
pr_title="${pr_title// /,}" # Replace spaces with commas.
|
pr_title="${pr_title// /,}" # Replace spaces with commas.
|
||||||
|
|
||||||
local pr_message="$(printf '[RFC] vim-patch:%s\n\n%s\n' "${pr_title#,}" "${pr_body}")"
|
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}'."
|
echo "Pushing to 'origin/${checked_out_branch}'."
|
||||||
output="$(git push origin "${checked_out_branch}" 2>&1)" &&
|
output="$(git push origin "${checked_out_branch}" 2>&1)" &&
|
||||||
@@ -225,7 +233,7 @@ submit_pr() {
|
|||||||
echo
|
echo
|
||||||
echo "Cleaning up files."
|
echo "Cleaning up files."
|
||||||
local patch_file
|
local patch_file
|
||||||
for patch_file in ${patches[@]}; do
|
for patch_file in "${patches[@]}"; do
|
||||||
patch_file="vim-${patch_file}.patch"
|
patch_file="vim-${patch_file}.patch"
|
||||||
if [[ ! -f "${NEOVIM_SOURCE_DIR}/${patch_file}" ]]; then
|
if [[ ! -f "${NEOVIM_SOURCE_DIR}/${patch_file}" ]]; then
|
||||||
continue
|
continue
|
||||||
@@ -241,12 +249,14 @@ list_vim_patches() {
|
|||||||
printf "\nVim patches missing from Neovim:\n"
|
printf "\nVim patches missing from Neovim:\n"
|
||||||
|
|
||||||
# Get commits since 7.4.602.
|
# 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
|
local vim_commit
|
||||||
for vim_commit in ${vim_commits}; do
|
for vim_commit in ${vim_commits}; do
|
||||||
local is_missing
|
local is_missing
|
||||||
local vim_tag=$(cd "${VIM_SOURCE_DIR}" && git describe --tags --exact-match "${vim_commit}" 2>/dev/null)
|
local vim_tag
|
||||||
|
vim_tag="$(cd "${VIM_SOURCE_DIR}" && git describe --tags --exact-match "${vim_commit}" 2>/dev/null)"
|
||||||
if [[ -n "${vim_tag}" ]]; then
|
if [[ -n "${vim_tag}" ]]; then
|
||||||
local patch_number="${vim_tag:5}" # Remove prefix like "v7.4."
|
local patch_number="${vim_tag:5}" # Remove prefix like "v7.4."
|
||||||
# Tagged Vim patch, check version.c:
|
# Tagged Vim patch, check version.c:
|
||||||
@@ -283,8 +293,10 @@ review_commit() {
|
|||||||
local neovim_patch_url="${neovim_commit_url}.patch"
|
local neovim_patch_url="${neovim_commit_url}.patch"
|
||||||
|
|
||||||
local git_patch_prefix='Subject: \[PATCH\] '
|
local git_patch_prefix='Subject: \[PATCH\] '
|
||||||
local neovim_patch="$(curl -Ssf "${neovim_patch_url}")"
|
local neovim_patch
|
||||||
local vim_version="$(head -n 4 <<< "${neovim_patch}" | sed -n "s/${git_patch_prefix}vim-patch:\([a-z0-9.]*\)$/\1/p")"
|
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
|
echo
|
||||||
if [[ -n "${vim_version}" ]]; then
|
if [[ -n "${vim_version}" ]]; then
|
||||||
@@ -300,9 +312,12 @@ review_commit() {
|
|||||||
|
|
||||||
local vim_patch_url="${vim_commit_url}.patch"
|
local vim_patch_url="${vim_commit_url}.patch"
|
||||||
|
|
||||||
local expected_commit_message="$(commit_message)"
|
local expected_commit_message
|
||||||
local message_length="$(wc -l <<< "${expected_commit_message}")"
|
expected_commit_message="$(commit_message)"
|
||||||
local commit_message="$(tail -n +4 <<< "${neovim_patch}" | head -n "${message_length}")"
|
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
|
if [[ "${commit_message#${git_patch_prefix}}" == "${expected_commit_message}" ]]; then
|
||||||
echo "✔ Found expected commit message."
|
echo "✔ Found expected commit message."
|
||||||
else
|
else
|
||||||
@@ -347,7 +362,7 @@ review_pr() {
|
|||||||
|
|
||||||
local pr_commit_url
|
local pr_commit_url
|
||||||
local reply
|
local reply
|
||||||
for pr_commit_url in ${pr_commit_urls[@]}; do
|
for pr_commit_url in "${pr_commit_urls[@]}"; do
|
||||||
review_commit "${pr_commit_url}"
|
review_commit "${pr_commit_url}"
|
||||||
if [[ "${pr_commit_url}" != "${pr_commit_urls[-1]}" ]]; then
|
if [[ "${pr_commit_url}" != "${pr_commit_urls[-1]}" ]]; then
|
||||||
read -p "Continue with next commit (Y/n)? " -n 1 -r reply
|
read -p "Continue with next commit (Y/n)? " -n 1 -r reply
|
||||||
|
Reference in New Issue
Block a user