summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaël Bonithon <gael@xfce.org>2021-05-12 13:39:40 +0200
committerSimon Steinbeiß <ochosi@xfce.org>2021-06-08 07:26:21 +0000
commit2266437dc8afad8d2bb60516d92dc636402de6c7 (patch)
treee40d58b7c1a34ccc117927b1e257594a212d15b1
parent2c3d0deb8b512e1e4f8f5647a2ff893b4f365cc7 (diff)
downloadxfce4-dev-tools-2266437dc8afad8d2bb60516d92dc636402de6c7.tar.gz
xfce-do-release: A review of confirmation prompts
* Abort on failure in `sanity_checks()` * Always test if the version specified exists as a git tag * Always have a default choice, indicated by a capital letter * Remove unused function `get_on_with_it()`
-rwxr-xr-xhelpers/xfce-do-release65
1 files changed, 37 insertions, 28 deletions
diff --git a/helpers/xfce-do-release b/helpers/xfce-do-release
index 0e32d5c..ca4604f 100755
--- a/helpers/xfce-do-release
+++ b/helpers/xfce-do-release
@@ -12,22 +12,34 @@ sanity_checks () {
if [ "$is_git" != "true" ]; then
exit 1
fi
+
current_branch=$(git rev-parse --abbrev-ref HEAD)
if [ "$current_branch" != "master" ]; then
if [[ "$current_branch" == *"xfce-4"* ]]; then
echo "You are on a maintenance branch."
else
printf "\e[1mWarning:\e[0m You are not on the master branch.\n"
- read -n 1 -s -p "Do you really want to continue?"
+ read -n 1 -p "Do you really want to continue? ([y]es, [N]o) " response
+ printf "\n"
+ if [ "$response" != "y" ]; then
+ exit 1
+ fi
fi
fi
+
echo "Updating $current_branch to avoid conflicts..."
- git pull
if [ -n "$(git status --untracked-files=no --porcelain)" ]; then
printf "\e[1mWarning:\e[0m The working directory is not clean.\nYou have the following unstaged or uncommitted changes:\n"
git status --untracked-files=no -s
- read -n 1 -s -p "Do you really want to continue?"
+ read -n 1 -p "Do you really want to continue? ([y]es, [N]o) " response
+ printf "\n"
+ if [ "$response" != "y" ]; then
+ exit 1
+ fi
+ else
+ git pull
fi
+
if ! which docker &>/dev/null; then
echo "INFO: please install docker to support building in a clean environment."
elif which xfce-build &>/dev/null; then
@@ -89,22 +101,26 @@ test_parameters () {
new_patch=$(echo "$(($latest_patch + 1))")
# Get the version
- if [ -n "$2" ]; then
- echo "Version: $version"
- else
- read -p "Specify a version (Default: $latest_major.$latest_minor.$new_patch): " new_version
- if [ "$new_version" = "" ]; then
+ if [ -z "$2" ]; then
+ read -p "Specify a version (Default: $latest_major.$latest_minor.$new_patch): " version
+ if [ -z "$version" ]; then
version="$(echo "$latest_major.$latest_minor.$new_patch")"
- echo "Version: $version"
- else
- if [ "$(git tag | grep -c $new_version\$)" = "1" ]; then
- read -n 1 -p "\e[1mWarning:\e[0m The version you specified ('$new_version') exists as a git tag. Do you really want to release again?"
- fi
- version="$(echo "$new_version")"
- echo "Version: $version"
fi
+ else
+ version=$2
fi
+ if [ "$(git tag | grep -c $version\$)" = "1" ]; then
+ printf "\e[1mWarning:\e[0m The version you specified ('$version') exists as a git tag. "
+ read -n 1 -p "Do you really want to release again? ([y]es, [N]o) " response
+ printf "\n"
+ if [ "$response" != "y" ]; then
+ exit 1
+ fi
+ fi
+
+ echo "Version: $version"
+
# Split up the actual version number so we can re-use it later
semantic_version=( ${version//./ } )
version_major="${semantic_version[0]}"
@@ -117,17 +133,10 @@ step () {
printf "\n\n \e[1mStep $steps: $1\e[0m\n ==================\n"
}
-# Just pause for user confirmation
-get_on_with_it () {
- read -n 1 -p " → Done?"
- let steps++
- let steps_complete++
-}
-
# Ask whether the step should be executed
run_command () {
let steps++
- read -n 1 -p " → Do it? ([y]es, [n]o, [s]kip)" response
+ read -n 1 -p " → Do it? ([y]es, [N]o, [s]kip) " response
printf "\n"
if [ "$response" = "y" ]; then
eval $1 && eval $2 && eval $3
@@ -137,7 +146,7 @@ run_command () {
printf "\n Step $(( $steps - 1 )) skipped."
return
else
- read -n 1 -p " Step $(( $steps - 1 )) aborted. Do you really want to quit? ([y]es, [n]o)" abort
+ read -n 1 -p " Step $(( $steps - 1 )) aborted. Do you really want to quit? ([y]es, [N]o) " abort
if [ "$abort" = "y" ]; then
printf "\n Aborted. (Steps complete: $steps_complete)\n"
exit 0
@@ -149,11 +158,11 @@ run_command () {
}
edit () {
- read -n 1 -p " → Accept? ([y]es, [e]dit" response
- if [ "$response" = "y" ]; then
- printf "\n ✓ Accepted.\n"
- elif [ "$response" = "e" ]; then
+ read -n 1 -p " → Accept? ([Y]es, [e]dit) " response
+ if [ "$response" = "e" ]; then
$(git config --default "${EDITOR:-vi}" --global core.editor) $1
+ else
+ printf "\n ✓ Accepted.\n"
fi
}