aboutsummaryrefslogtreecommitdiff
path: root/scripts/vim-patch.sh
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2021-10-02 21:15:01 +0800
committerGitHub <noreply@github.com>2021-10-02 06:15:01 -0700
commita3b5b4a31e246ce0db2bb4a1474fd11c88081062 (patch)
treeff7404bd687d280cf3c39677c160aa286855d03d /scripts/vim-patch.sh
parent724ffe7095424e7acdbde8d0b12f357809561fdf (diff)
downloadrneovim-a3b5b4a31e246ce0db2bb4a1474fd11c88081062.tar.gz
rneovim-a3b5b4a31e246ce0db2bb4a1474fd11c88081062.tar.bz2
rneovim-a3b5b4a31e246ce0db2bb4a1474fd11c88081062.zip
feat(vim-patch.sh): better detection of remote name #15846
Diffstat (limited to 'scripts/vim-patch.sh')
-rwxr-xr-xscripts/vim-patch.sh43
1 files changed, 29 insertions, 14 deletions
diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh
index f4b817dfff..d92480abb9 100755
--- a/scripts/vim-patch.sh
+++ b/scripts/vim-patch.sh
@@ -125,8 +125,12 @@ commit_message() {
}
find_git_remote() {
- git_remote=$(git remote -v \
- | awk '$2 ~ /github.com[:\/]neovim\/neovim/ && $3 == "(fetch)" {print $1; exit}')
+ local git_remote
+ if [[ "${1-}" == fork ]]; then
+ git_remote=$(git remote -v | awk '$2 !~ /github.com[:\/]neovim\/neovim/ && $3 == "(fetch)" {print $1; exit}')
+ else
+ git_remote=$(git remote -v | awk '$2 ~ /github.com[:\/]neovim\/neovim/ && $3 == "(fetch)" {print $1; exit}')
+ fi
if [[ -z "$git_remote" ]]; then
git_remote="origin"
fi
@@ -268,8 +272,8 @@ stage_patch() {
get_vimpatch "$1"
local try_apply="${2:-}"
- local git_remote
- git_remote="$(find_git_remote)"
+ local nvim_remote
+ nvim_remote="$(find_git_remote)"
local checked_out_branch
checked_out_branch="$(git rev-parse --abbrev-ref HEAD)"
@@ -277,16 +281,16 @@ stage_patch() {
msg_ok "Current branch '${checked_out_branch}' seems to be a vim-patch"
echo " branch; not creating a new branch."
else
- printf '\nFetching "%s/master".\n' "${git_remote}"
- output="$(git fetch "${git_remote}" master 2>&1)" &&
+ printf '\nFetching "%s/master".\n' "${nvim_remote}"
+ output="$(git fetch "${nvim_remote}" master 2>&1)" &&
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'."
+ echo "Creating new branch '${nvim_branch}' based on '${nvim_remote}/master'."
cd "${NVIM_SOURCE_DIR}"
- output="$(git checkout -b "${nvim_branch}" "${git_remote}/master" 2>&1)" &&
+ output="$(git checkout -b "${nvim_branch}" "${nvim_remote}/master" 2>&1)" &&
msg_ok "${output}" ||
(msg_err "${output}"; false)
fi
@@ -362,13 +366,13 @@ submit_pr() {
exit 1
fi
- local git_remote
- git_remote="$(find_git_remote)"
+ local nvim_remote
+ nvim_remote="$(find_git_remote)"
local pr_body
- pr_body="$(git log --grep=vim-patch --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' "${nvim_remote}"/master..HEAD)"
local patches
# 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=("$(git log --grep=vim-patch --reverse --format='%s' "${nvim_remote}"/master..HEAD | sed 's/: .*//')")
# shellcheck disable=SC2206
patches=(${patches[@]//vim-patch:}) # Remove 'vim-patch:' prefix for each item in array.
local pr_title="${patches[*]}" # Create space-separated string from array.
@@ -376,8 +380,19 @@ submit_pr() {
pr_title="$(printf 'vim-patch:%s' "${pr_title#,}")"
if [[ $push_first -ne 0 ]]; then
- echo "Pushing to 'origin/${checked_out_branch}'."
- output="$(git push origin "${checked_out_branch}" 2>&1)" &&
+ local push_remote
+ push_remote="$(git config --get branch."${checked_out_branch}".pushRemote || true)"
+ if [[ -z "$push_remote" ]]; then
+ push_remote="$(git config --get remote.pushDefault || true)"
+ if [[ -z "$push_remote" ]]; then
+ push_remote="$(git config --get branch."${checked_out_branch}".remote || true)"
+ if [[ -z "$push_remote" ]] || [[ "$push_remote" == "$nvim_remote" ]]; then
+ push_remote="$(find_git_remote fork)"
+ fi
+ fi
+ fi
+ echo "Pushing to '${push_remote}/${checked_out_branch}'."
+ output="$(git push "${push_remote}" "${checked_out_branch}" 2>&1)" &&
msg_ok "${output}" ||
(msg_err "${output}"; false)