tag_release: by default, prompt before pushing

This commit is contained in:
Benjamin Gilbert 2017-11-07 16:10:10 -08:00
parent 7ec72c7f88
commit 463d191d6b

View File

@ -4,6 +4,22 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # 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=$(dirname $(readlink -f "$0"))
. "${SCRIPT_ROOT}/common.sh" || exit 1 . "${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}" \ DEFINE_string branch_projects "${DEFAULT_BRANCH_PROJECTS}" \
"Branch the named projects (with a 'coreos/' prefix) in the manifest." "Branch the named projects (with a 'coreos/' prefix) in the manifest."
DEFINE_boolean push ${FLAGS_FALSE} "Push to public manifest repository." 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 remote "origin" "Remote name or URL to push to."
DEFINE_string signer '' "Alternate GPG key ID used to sign the tag." 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 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=$(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}" 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 done
fi fi
fi fi
@ -163,7 +180,7 @@ if [[ ${FLAGS_push} -eq ${FLAGS_TRUE} ]]; then
fi fi
info 'Pushing manifest updates' info 'Pushing manifest updates'
git push "${FLAGS_remote}" $master \ git_confirm push "${FLAGS_remote}" $master \
"refs/heads/${BRANCH_NAME}" \ "refs/heads/${BRANCH_NAME}" \
"refs/tags/${TAG_NAME}" "refs/tags/${TAG_NAME}"
fi fi