diff --git a/hack/cherry_pick_pull.sh b/hack/cherry_pick_pull.sh index 5b35be812ba..4e9dfdef5ef 100755 --- a/hack/cherry_pick_pull.sh +++ b/hack/cherry_pick_pull.sh @@ -44,8 +44,8 @@ if [[ -z ${GITHUB_USER:-} ]]; then exit 1 fi -if ! which hub > /dev/null; then - echo "Can't find 'hub' tool in PATH, please install from https://github.com/github/hub" +if ! command -v gh > /dev/null; then + echo "Can't find 'gh' tool in PATH, please install from https://github.com/cli/cli" exit 1 fi @@ -71,6 +71,9 @@ if [[ "$#" -lt 2 ]]; then exit 2 fi +# Checks if you are logged in. Will error/bail if you are not. +gh auth status + if git_status=$(git status --porcelain --untracked=no 2>/dev/null) && [[ -n "${git_status}" ]]; then echo "!!! Dirty tree. Clean up and try again." exit 1 @@ -109,7 +112,6 @@ declare -r NEWBRANCHUNIQ echo "+++ Creating local branch ${NEWBRANCHUNIQ}" cleanbranch="" -prtext="" gitamcleanup=false function return_to_kansas { if [[ "${gitamcleanup}" == "true" ]]; then @@ -126,9 +128,6 @@ function return_to_kansas { if [[ -n "${cleanbranch}" ]]; then git branch -D "${cleanbranch}" >/dev/null 2>&1 || true fi - if [[ -n "${prtext}" ]]; then - rm "${prtext}" - fi fi } trap return_to_kansas EXIT @@ -140,24 +139,18 @@ function make-a-pr() { echo echo "+++ Creating a pull request on GitHub at ${GITHUB_USER}:${NEWBRANCH}" - # This looks like an unnecessary use of a tmpfile, but it avoids - # https://github.com/github/hub/issues/976 Otherwise stdin is stolen - # when we shove the heredoc at hub directly, tickling the ioctl - # crash. - prtext="$(mktemp -t prtext.XXXX)" # cleaned in return_to_kansas local numandtitle numandtitle=$(printf '%s\n' "${SUBJECTS[@]}") - cat >"${prtext}" <