From 463d191d6b8db8aad801080ab6681e33e124665e Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Tue, 7 Nov 2017 16:10:10 -0800 Subject: [PATCH] tag_release: by default, prompt before pushing --- tag_release | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tag_release b/tag_release index 87c54461cf..6cf2fad6f6 100755 --- a/tag_release +++ b/tag_release @@ -4,6 +4,22 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +git_confirm() { + local response + if [[ ${FLAGS_force} -ne ${FLAGS_TRUE} ]]; then + echo "Executing: git $@" + while [[ "${response}" != "y" ]]; do + echo -n "Proceed? (y/n) " + read response + if [[ "${response}" == "n" ]]; then + echo "Aborting." + exit 1 + fi + done + fi + git "$@" +} + SCRIPT_ROOT=$(dirname $(readlink -f "$0")) . "${SCRIPT_ROOT}/common.sh" || exit 1 @@ -38,6 +54,7 @@ DEFINE_boolean branch ${DEFAULT_BRANCH} "Release branch, diverge from master" DEFINE_string branch_projects "${DEFAULT_BRANCH_PROJECTS}" \ "Branch the named projects (with a 'coreos/' prefix) in the manifest." DEFINE_boolean push ${FLAGS_FALSE} "Push to public manifest repository." +DEFINE_boolean force ${FLAGS_FALSE} "Don't prompt before pushing." DEFINE_string remote "origin" "Remote name or URL to push to." DEFINE_string signer '' "Alternate GPG key ID used to sign the tag." @@ -151,7 +168,7 @@ if [[ -n "${FLAGS_branch_projects}" ]]; then for project in ${FLAGS_branch_projects}; do info=$(sed -n 's,.* name="coreos/'${project}'".* path="\([^"]*\)".* revision="\([0-9A-Fa-f]*\)".*,\2 \1,p' release.xml) info "Creating branch ${BRANCH_NAME} at ${info%% *} in ${project}" - git -C "${REPO_ROOT}/${info#* }" push "${remote}" "${info%% *}:refs/heads/${BRANCH_NAME}" + git_confirm -C "${REPO_ROOT}/${info#* }" push "${remote}" "${info%% *}:refs/heads/${BRANCH_NAME}" done fi fi @@ -163,7 +180,7 @@ if [[ ${FLAGS_push} -eq ${FLAGS_TRUE} ]]; then fi info 'Pushing manifest updates' - git push "${FLAGS_remote}" $master \ + git_confirm push "${FLAGS_remote}" $master \ "refs/heads/${BRANCH_NAME}" \ "refs/tags/${TAG_NAME}" fi