Skip to content
This repository was archived by the owner on Oct 17, 2025. It is now read-only.

Commit b87f537

Browse files
committed
## Version 1.0.15
- Improved upgrade-cli - Refactored include.sh into smud-main.sh and include.sh
1 parent 42292f5 commit b87f537

File tree

9 files changed

+497
-361
lines changed

9 files changed

+497
-361
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Version 1.0.15
2+
- Improved upgrade-cli
3+
- Refactored include.sh into smud-main.sh and include.sh
4+
15
## Version 1.0.14
26
- Improved argument handling
37
- Improved array iteration

smud-cli/download-and-install-cli.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ if [ -d $download_folder ]; then
109109
fi
110110

111111
rm -rf $download_folder
112-
. $destination_folder/install-cli.sh
112+
. $destination_folder/install-cli.sh "$@"
113113
fi
114114

115115
IFS=$old_SEP

smud-cli/functions-init.sh

Lines changed: 61 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,17 @@ set_upstream()
3636
i=0
3737

3838
if [ "$new_upstream" ]; then
39-
remove_upstream_command="git remote rm upstream"
40-
run_command remove-upstream --command-from-var=remove_upstream_command --debug-title='Removing upstream config URL'
39+
run_command --command="git remote rm upstream" --force-debug-title='Removing upstream config URL'
4140
if [ "$new_upstream" = "-" ]; then
4241
println_not_silent "Upstream is removed" $gray
4342
exit
4443
else
45-
add_upstream_command="git remote add upstream $new_upstream"
46-
run_command add_upstream_command --command-from-var=add_upstream_command --debug-title='Adding upstream with user specified URL'
44+
run_command --command="git remote add upstream $new_upstream" --force-debug-title='Adding upstream with user specified URL'
4745
println_not_silent "Upstream configured with '$new_upstream' " $gray
4846
fi
4947
elif [ ! "$new_upstream" ]; then
5048
new_upstream="$default_upstream"
51-
add_upstream_command="git remote add upstream $new_upstream"
52-
run_command add_upstream_command --command-from-var=add_upstream_command --debug-title='Adding upstream with default URL'
49+
run_command --command="git remote add upstream $new_upstream" --force-debug-title='Adding upstream with default URL'
5350
println_not_silent "Upstream configured with '$new_upstream' " $gray
5451
elif [ ! "$caller" ]; then
5552
println_not_silent "Upstream alredy configured with '$new_upstream' " $gray
@@ -64,33 +61,40 @@ set_origin()
6461
fi
6562

6663
exit_if_is_not_a_git_repository "Setting remote.origin.url require a git repository!"
67-
64+
6865
# Check if origin exists
69-
check_origin_command="git config --get remote.origin.url"
70-
run_command --check-origin --command-from-var=check_origin_command --return-var=remote_origin --debug-title='Checking if remote.origin.url exist in git config'
66+
git_config_command="git config --get remote.origin.url"
67+
run_command --command-in-var=git_config_command --return-var=remote_origin --debug-title='Checking if remote.origin.url exist in git config'
7168
# If string is empty, set the remote origin url
7269
if [ ! "$remote_origin" ]; then
73-
ask remote_origin $yellow "Remote repository origin is not set, please enter URL for the remote origin.\nOrigin URL:" "true"
70+
ask remote_origin $yellow "Remote repository origin is not set, please enter URL for the remote origin.\nOrigin URL:" "true"
7471
if [ "$remote_origin" ]; then
75-
add_origin_command="git remote add origin $remote_origin"
76-
run_command --set-origin --command-from-var=add_origin_command --return-var=dummy --debug-title='Adding remote origin' || return
72+
println_not_silent "Setting remote origin '$remote_origin'" $gray
73+
run_command --command="git remote add origin $remote_origin" --force-debug-title='Setting remote origin'
7774
fi
75+
else
76+
println_not_silent "Remote origin '$remote_origin' already set." $gray
7877
fi
7978
}
8079

8180
merge_upstream()
8281
{
83-
if [ "$skip_init_feature" ];then
82+
if [ "$skip_init_feature" ] && [ ! "$merge" ];then
8483
return
8584
fi
8685

87-
if [ "$skip_auto_update" ]; then
86+
if [ "$skip_auto_update" ] && [ ! "$merge" ]; then
8887
return
8988
fi
90-
println_not_silent "Merging upstream into local branch..." $gray
91-
merge_upstream_command="git merge upstream/main"
92-
run_command merge-upstream --command-from-var=merge_upstream_command --return-var=dummy --debug-title='Merging upstream repository into local branch' || return
9389

90+
if [ "$merge" ] && [ "$merge" != "true" ]; then
91+
git__setup_source_config "$merge"
92+
fi
93+
if [ "$source_branch" ]; then
94+
msg="Merging upstream '$source_branch' into local branch '$current_branch' ..."
95+
println_not_silent "Merging upstream '$source_branch' into local branch '$current_branch' ..." $gray
96+
run_command --command="git merge $source_branch" --return-in-var=dev_null --debug-title="$msg"
97+
fi
9498
}
9599

96100
fetch_origin()
@@ -107,26 +111,36 @@ fetch_origin()
107111
return
108112
fi
109113

110-
println_not_silent "Fetching origin..." $gray
111-
fetch_origin_command="git fetch origin"
112-
run_command fetch-origin --command-from-var=fetch_origin_command --return-var=dummy --debug-title='Fetching origin' || return
114+
println_not_silent "Fetching origin '$remote_origin' into branch '$current_branch'..." $gray
115+
run_command --command="git fetch origin" --return-in-var=dev_null --debug-title='Fetching origin'
113116
}
114117

118+
git_push()
119+
{
120+
if [ ! "$remote_origin" ]; then
121+
println_not_silent "Missing remote-origin. Pushing skipped..." $gray
122+
return
123+
fi
124+
125+
println_not_silent "Push current branch '$current_branch' to origin-url '$remote_origin'..." $gray
126+
run_command --command="git push origin $current_branch" --return-in-var=dev_null --debug-title='Push to remote'
127+
}
128+
115129
init_repo()
116130
{
117-
init_command="git init"
118131
if [ "$skip_init_feature" ];then
119132
return
120133
fi
134+
121135
if [ ! "$is_repo" ];then
122-
run_command init-repo --command-from-var=init_command --return-var=dummy --debug-title='Initializing repository' || return
136+
run_command --command="git init" --return-in-var=dev_null --debug-title='Initializing repository' || return
123137
is_repo="true"
124138

125139
branches="$(git branch)"
126140
if [ ! -n "$branches" ]; then
127141
# "main" possibly not default branch name so create it
128-
create_main_branch="git checkout -b main"
129-
run_command checkout-main --command-from-var=create_main_branch --return-var=dummy --debug-title='Creating main branch' || return
142+
git_checkout_command="git checkout -b main"
143+
run_command --command-in-var git_checkout_command --return-in-var=dev_null --debug-title='Creating main branch' || return
130144
fi
131145
fi
132146
git__setup 'true'
@@ -138,8 +152,7 @@ fetch_upstream()
138152
return
139153
fi
140154

141-
fetch_upstream_command="git fetch upstream"
142-
run_command fetch-upstream --command-from-var=fetch_upstream_command --return-var=dummy --debug-title='Fetching upstream' || return
155+
run_command --command="git fetch upstream" --return-in-var=dev_null --force-debug-title='Fetching upstream'
143156
}
144157

145158
init_upstream_url()
@@ -160,7 +173,6 @@ init_upstream_url()
160173
set_upstream "$upstream_url"
161174
print_debug "upstream_url: $upstream_url"
162175
fi
163-
164176
}
165177

166178
# Initalizes repo, upstream and origin if not configured. Will always fetch upstream when called.
@@ -184,6 +196,11 @@ init()
184196
printf "${yellow}default-branch:${normal} \n"
185197
printf " With Only ${green}$func${normal}, ${yellow}default-branch${normal} will be configured to '${bold}main${normal}' . \n"
186198
printf " With ${green}$func ${yellow}${bold}--default-branch <value>${normal}${normal}, ${bold}default-branch '<value>'${normal} will be configured. \n"
199+
printf "${yellow}merge upstream:${normal} \n"
200+
printf " With ${green}$func ${yellow}${bold}--merge${normal} the '${bold}git merge upstream/main${normal}' command will be runned. \n"
201+
printf " With ${green}$func ${yellow}${bold}--merge --push${normal} the ${gray}'git merge upstream/main; ${normal}${bold}git push${normal}' command will be runned. \n"
202+
printf " With ${green}$func ${yellow}${bold}--merge <branch>${normal}${normal} the '${bold}git merge upstream/${yellow}${bold}<branch>${normal}' command will be runned. \n"
203+
printf " With ${green}$func ${yellow}${bold}--merge <branch> --push${normal}${normal} the '${gray}git merge upstream/<branch>${normal}; ${bold}git push${normal}' command will be runned. \n"
187204
printf "Show ${yellow}configs:${normal} \n"
188205
printf " ${green}$func${normal} ${yellow}--configs${normal} will list all repository config key/values. ${yellow}--show${normal} or ${yellow}--settings${normal} can be used as well. \n"
189206
printf " ${green}$func${normal} ${yellow}--show${normal} or ${yellow}--settings${normal} can be used as well. \n"
@@ -204,11 +221,10 @@ init()
204221
set_upstream "-"
205222
return
206223
fi
207-
208224
if [ ! "$is_repo" ]; then
209225
local yes_no="yes"
210226
if [ ! "$silent" ]; then
211-
ask yes_no $yellow "The current directory does not seem to be a git repository\nWould you like to initialize the repository and merge the remote upstream? (yes/no)"
227+
ask yes_no $yellow "The current directory does not seem to be a git repository\nWould you like to initialize the repository and merge the remote upstream (Yes/No)?" "-" "yes"
212228
fi
213229
if [ ! "$yes_no" = "yes" ]; then
214230
println_not_silent "Aborting" $yellow
@@ -220,53 +236,34 @@ init()
220236
fetch_upstream
221237
merge_upstream
222238
init_repo
239+
if [ "$merge" ]; then
240+
run_push=$force_push
241+
fi
223242
else
224243
init_upstream_url
225244
fetch_upstream
226-
fi
227-
228-
if [ "$is_repo" ]; then
229-
230-
if [ ! "$source_branch" ]; then
231-
232-
if [ "$current_branch" ]; then
233-
source_branch="$(git config --get source.$current_branch)"
234-
fi
235-
fi
236-
237-
238-
if [ ! "$source_branch" ]; then
239-
source_branch="upstream/$default_branch"
240-
fi
241-
242-
243-
old=""
244-
if [ "$current_branch" ]; then
245-
old="$(git config --get source.$current_branch)"
246-
fi
247-
248-
if [ ! "$old" = "$source_branch" ] || [ ! "$old" ] ; then
249-
250-
if [ "$old" ] && [ "$current_branch" ]; then
251-
dummy="$(git config --unset source.$current_branch)"
252-
fi
253-
254-
if [ "$current_branch" ] && [ "$source_branch" ]; then
255-
dummy="$(git config --add source.$current_branch $source_branch)"
256-
fi
245+
if [ "$merge" ]; then
246+
merge_upstream
247+
run_push=$force_push
257248
fi
258249
fi
259250

251+
git__setup_source_config
260252

261253
if [ ! "$remote_origin" ]; then
262-
println_not_silent "Setting and fetching origin" $gray
263254
set_origin
264-
fetch_origin
255+
if [ ! "$run_push" ]; then
256+
fetch_origin
257+
fi
265258
println_not_silent "Initalization complete." $green
266259
fi
267260

261+
if [ "$run_push" ]; then
262+
git_push
263+
fi
264+
268265
if [ "$configs" ]; then
269-
config_command="git config -l"
270-
run_command config-list --command-var config_command --skip-error
266+
git_config_command="git config -l"
267+
run_command --command-in-var git_config_command --skip-error
271268
fi
272269
}

smud-cli/functions-list.sh

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ list()
8383
diff_filter='--diff-filter=ACMRT'
8484
println_not_silent "List new products ready for installation:${normal}" $white
8585
elif [ "$installed" ]; then
86-
println_not_silent "List current products installed:" $white
86+
if [ "$changed" ]; then
87+
println_not_silent "List released installed products:" $white
88+
else
89+
println_not_silent "List installed products:" $white
90+
fi
8791
else
8892
println_not_silent "List new or updated products ready for installation:" $white
8993
fi
@@ -140,6 +144,10 @@ product_infos__find_latest_products_with_version()
140144

141145
resolve_team_array
142146

147+
if [ "$responsible" ] && [ ${#teams[@]} -eq 0 ]; then
148+
return
149+
fi
150+
143151
{
144152
app_files_command=$(sed -e "s|__app_files_filter__|$app_files_filter|g" -e "s|__filter__|$filter|g" <<< $app_files_command )
145153
print_verbose "**** Before app_files_command"
@@ -661,9 +669,9 @@ product_infos__print()
661669
# echo "{ stage: '$product_stage', product_name: '$product_name', latest_version: '$latest_version', commit: '$commit', product_info: '${product_infos[${stage_product_name}]}' }"
662670
if [ "$show_tags_in_list" ]; then
663671
if [ "$show_tags_in_list" = "reverse" ]; then
664-
tags="$(get_tags "'$latest_version'" "'$current_version'")"
672+
get_tags tags "'$latest_version'" "'$current_version'"
665673
else
666-
tags="$(get_tags "'$current_version'" "'$latest_version'")"
674+
get_tags tags "'$current_version'" "'$latest_version'"
667675
fi
668676

669677
if [ "$major" ] && [ ! "$tags" = "MAJOR" ];then
@@ -865,33 +873,43 @@ get_next_stage_version()
865873

866874
get_tags()
867875
{
876+
local -n get_tags_tags="$1"
877+
878+
get_tags_tags=""
868879
replace_reg_exp="s/'//g"
869-
cur_ver="$(echo "$1" | sed -e $replace_reg_exp)"
870-
latest_ver="$(echo "$2" | sed -e $replace_reg_exp)"
880+
cur_ver="$(echo "$2" | sed -e $replace_reg_exp)"
881+
latest_ver="$(echo "$3" | sed -e $replace_reg_exp)"
871882
if [ ! "$cur_ver" ] && [ "$latest_ver" ]; then
872-
echo "NEW"
883+
get_tags_tags="NEW"
873884
return
874885
elif [ "$cur_ver" ] && [ "$latest_ver" ]; then
875886
# cur_ver_array=$(echo "$cur_ver" | tr "." "\n")
876887
# latest_ver_array=$(echo "$latest_ver" | tr "." "\n")
877888
cur_ver_major="$(echo "$cur_ver" | cut -d "." -f 1)"
889+
# cur_ver_major="${cur_ver_major%%[[:cntrl:]]}"
878890
latest_ver_major="$(echo "$latest_ver" | cut -d "." -f 1)"
879-
if [ ! "$cur_ver_major" = "$latest_ver_major" ];then
880-
echo "MAJOR"
891+
# latest_ver_major="${latest_ver_major%%[[:cntrl:]]}"
892+
if [ "$cur_ver_major" != "$latest_ver_major" ];then
893+
get_tags_tags="MAJOR"
881894
return
882895
fi
896+
883897
cur_ver_minor="$(echo "$cur_ver" | cut -d "." -f 2)"
898+
# cur_ver_minor="${cur_ver_minor%%[[:cntrl:]]}"
884899
latest_ver_minor="$(echo "$latest_ver" | cut -d "." -f 2)"
885-
if [ ! "$cur_ver_minor" = "$latest_ver_minor" ];then
886-
echo "MINOR"
900+
# latest_ver_minor="${latest_ver_minor%%[[:cntrl:]]}"
901+
if [ "$cur_ver_minor" != "$latest_ver_minor" ];then
902+
get_tags_tags="MINOR"
887903
return
888904
fi
889905

890906
cur_ver_patch="$(echo "$cur_ver" | cut -d "." -f 3)"
891907
latest_ver_patch="$(echo "$latest_ver" | cut -d "." -f 3)"
892-
if [ ! "$cur_ver_patch" = "$latest_ver_patch" ];then
893-
echo "patch"
894-
return
908+
if [ "$cur_ver_patch" != "$latest_ver_patch" ];then
909+
if [ ! "${cur_ver_patch%%[[:cntrl:]]}" = "${latest_ver_patch%%[[:cntrl:]]}" ];then
910+
get_tags_tags="patch"
911+
return
912+
fi
895913
fi
896914
fi
897915
}

0 commit comments

Comments
 (0)