From 563f00e6756d6c949a3c11f330a92edc8dc55f6a Mon Sep 17 00:00:00 2001 From: dragondaddy Date: Tue, 14 Nov 2023 03:52:56 +0100 Subject: [PATCH] switch to release only if ahead of dev --- scripts/config | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/config b/scripts/config index 49b07ce..5f94714 100644 --- a/scripts/config +++ b/scripts/config @@ -66,10 +66,17 @@ get__free_footprint() { set__git_branch_mode() { - if [ "$git_branch_mode" -eq "0" ]; then - # If git_branch was set to 0, switch to "release" branch - (cd "$install_dir" && git checkout release) - ynh_print_info "Switching to \"release\" branch" + if [ "$git_branch_mode" -eq "0" ] + then + # We allow switch back to "release" only if the branch is ahead of "dev" + if [ -z "$(cd "$install_dir" && git log release..dev)" ] + then + # If git_branch was set to 0, switch to "release" branch + (cd "$install_dir" && git checkout release) + ynh_print_info "Switching to \"release\" branch" + else + ynh_print_err --message="\"release\" branch is behind your local \"dev\" branch, rolling back is not allowed here" + exit 0 elif [ "$git_branch_mode" -eq "1" ]; then # If git_branch was set to 1, switch to "dev" branch (cd "$install_dir" && git checkout dev)