From 5d0b015461242229e8599bde21e3bec0b9466e2a Mon Sep 17 00:00:00 2001 From: dragondaddy Date: Mon, 13 Nov 2023 15:39:55 +0100 Subject: [PATCH] Add option to switch to dev branch --- config_panel.toml | 12 ++++++++++++ scripts/config | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/config_panel.toml b/config_panel.toml index fbc4a7e..50623e8 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -4,6 +4,18 @@ version = "1.0" name.en = "Streams configuration" name.fr = "Configuration de Streams" + [main.git_branch_mode] + name.en = "'dev' branch" + name.fr = "Branche 'dev'" + + [main.git_branch_mode.git_branch_mode] + ask.en = "Switch to git 'dev' branch" + ask.fr = "Basculer sur la branche git 'dev'" + type = "boolean" + default = "0" + help.en = "Use at your own risk, if you know ewactly what you're doing." + help.fr = "À utiliser à vos risques et périls, si vous savez exactement ce que vous faîtes." + [main.php_fpm_config] name.en = "PHP-FPM configuration" name.fr = "Configuration de PHP-FPM" diff --git a/scripts/config b/scripts/config index 91c2de7..2890f16 100644 --- a/scripts/config +++ b/scripts/config @@ -22,6 +22,22 @@ current_fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) # SPECIFIC GETTERS FOR TOML SHORT KEY #================================================= +get__git_branch_mode() { + # Maintenance mode status + git_branch_mode_status="$(cd "$install_dir" && ynh_exec_as "$app" \ + git branch --show-current)" 2> /dev/null + if echo $git_branch_mode_status | grep -q "release" + then + echo "0" + elif echo $git_branch_mode_status | grep -q "dev" + then + echo "1" + else + ynh_print_err --message="Not using \"release\" or \"dev\" branch, please handle this in command line" + exit 0 + fi +} + get__fpm_footprint() { # Free footprint value for php-fpm # Check if current_fpm_footprint is an integer @@ -49,6 +65,22 @@ get__free_footprint() { # SPECIFIC SETTERS FOR TOML SHORT KEYS #================================================= + +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" && ynh_exec_as "$app" \ + git checkout release) + ynh_print_info "Switching to \"release\" branch" + elif [ "$git_branch_mode" -eq "1" ]; then + # If git_branch was set to 1, switch to "dev" branch + (cd "$install_dir" && ynh_exec_as "$app" \ + git checkout dev) + ynh_print_info "Switching to \"dev\" branch" + fi + ynh_app_setting_set --app=$app --key=git_branch_mode --value="$git_branch_mode" +} + set__fpm_footprint() { if [ "$fpm_footprint" != "specific" ] then