diff --git a/smud-cli/functions-list.sh b/smud-cli/functions-list.sh index b2814f0..f226358 100644 --- a/smud-cli/functions-list.sh +++ b/smud-cli/functions-list.sh @@ -151,7 +151,7 @@ product_infos__find_latest_products_with_version() product_names=() fi - progressbar__init $line_numbers 50 + progressbar__init $line_numbers 100 i=0 for line in "${changed_files[@]}" @@ -216,9 +216,10 @@ product_infos__find_latest_products_with_version() product_infos__find_latest_products_with_files() { - if [ "$skip_files" ]; then + if [ ! "$show_files" ]; then return fi + product_name="" if [ "$installed" ]; then files_command="git ls-files -- $filter $no_app_files_filter" @@ -241,7 +242,7 @@ product_infos__find_latest_products_with_files() product_yaml_product_names=() commit="" - progressbar__init $line_numbers 50 + progressbar__init $line_numbers 100 i=0 start_time=$(date +"%Y-%m-%d %H:%M:%S") @@ -393,7 +394,7 @@ product_infos__print() current_version="$(get_current_version)" fi - if [ ! "$skip_files" ]; then + if [ "$show_files" ]; then product_info__get_latest_files product_info files fi @@ -436,7 +437,7 @@ product_infos__print() if [ ! "$printed_product_header" ]; then files_header="" - if [ ! "$skip_files" ]; then + if [ "$show_files" ]; then files_header="FILES" fi diff --git a/smud-cli/functions-upgrade.sh b/smud-cli/functions-upgrade.sh index 24c4991..636020c 100644 --- a/smud-cli/functions-upgrade.sh +++ b/smud-cli/functions-upgrade.sh @@ -70,6 +70,39 @@ upgrade() return fi + if [ "$undo" ]; then + if [ "$undo" = "true" ]; then + print_error "You must add the commit to the --undo flag. Ex: --undo b3..." + return + fi + local has_undo_commit_command="git log $undo --max-count=1 --no-merges --oneline" + run_command --has-commits --command-var=has_undo_commit_command --return-var='has_undo_commit' --debug-title='Check if undo commit exists' || + { + print_error "Unabled to find commit '$undo'.\nUndo terminated...\n" + return + } + if [ ! "$has_undo_commit" ]; then + print_gray "No commit '$$undo' found. Undo terminated..." + return + fi + ask yes_no $yellow "Do you really want to reset to [$has_undo_commit]?\nThis is a destructive command. All changes newer than that commit will be lost!" + if [ "$yes_no" = "yes" ]; then + local flag="--hard" + if [ "$soft" ]; then + local flag="--soft" + fi + local git_reset_hard_command="git reset $flag $undo" + run_command --reset-to-commit --command-var=git_reset_hard_command --return-var='reset_result' --debug-title="Reset '$default_branch' to commit '$undo'" || + { + print_error "Failed to reset default branch '$default_branch' to commit '$undo'\n" + return + } + print_color $green "Default branch '$default_branch' successfully reset to commit '$undo'\n" + fi + + return + fi + local context="products" local upgrade_filter=$filter local yes_no="y" @@ -78,7 +111,7 @@ upgrade() if [ ! "$silent" ]; then ask yes_no $yellow "Do you want to upgrade the GitOps-model (Yes/No)?" fi - if [ ! "$yes_no" = "yes" ]; then + if [ "$yes_no" = "yes" ]; then local upgrade_filter=$devops_model_filter local context="GitOps-model files" print_gray "Swithced to '$context' context" diff --git a/smud-cli/include.sh b/smud-cli/include.sh index 411dcee..19451e2 100644 --- a/smud-cli/include.sh +++ b/smud-cli/include.sh @@ -180,8 +180,14 @@ ask() print_color $color $question read answer lower answer - print_gray "You selected: $answer" - + if [ "$1" = "yes_no" ]; then + if [ "$answer" = "yes" ] || [ "$answer" = "y" ] || [ "$answer" = "ja" ] || [ "$answer" = "j" ]; then + answer="yes" + elif [ "$answer" = "no" ] || [ "$answer" = "n" ] || [ "$answer" = "nei" ]; then + answer="no" + fi + fi + print_debug "You selected: $answer" } @@ -351,9 +357,14 @@ get_arg to_commit '--to-commit,-TC' get_arg from_date '--from-date,-FD' get_arg to_date '--to-date,-TD' get_arg grep '--grep' +get_arg undo '--undo,--reset' +get_arg soft '--soft' get_arg no_progress '--no-progress' "$silent" -get_arg skip_files '--skip-files' -get_arg files '--files' +get_arg skip_files '--skip-files,--no-files' +get_arg show_files '--show-files,--files' +if [ "$skip_files" ]; then + show_files="" +fi get_arg development '--development,-D,-DEV' get_arg external_test '--external-test,-ET'