Skip to content

Commit 3adae06

Browse files
committed
## Version 1.0.19
- Improved branch handling
1 parent f9c881e commit 3adae06

File tree

8 files changed

+264
-36
lines changed

8 files changed

+264
-36
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
## Version 1.0.17
1+
## Version 1.0.19
2+
- Improved branch handling
3+
4+
## Version 1.0.18
25
- Args refactor
36

47
## Version 1.0.16

smud-cli/functions-init.sh

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ set_upstream()
5555

5656
set_origin()
5757
{
58-
58+
# echo "***** set_origin"
5959
if [ "$skip_init_feature" ] || [ "$installed" ];then
6060
return
6161
fi
@@ -75,8 +75,29 @@ set_origin()
7575
else
7676
println_not_silent "Remote origin '$remote_origin' already set." $gray
7777
fi
78+
79+
set_branch_origin
7880
}
81+
set_branch_origin()
82+
{
83+
git_config_command="git config --get branch.$current_branch.remote"
84+
run_command --command-in-var=git_config_command --return-var=branch_remote_origin --debug-title="Checking if branch.$current_branch.remote exist in git config"
85+
if [ ! "$branch_remote_origin" ]; then
86+
branch_remote_origin="origin"
87+
println_not_silent "Setting branch remote origin to '$branch_remote_origin'" $gray
88+
git_config_command="git config --add branch.$current_branch.remote $branch_remote_origin"
89+
run_command --command-in-var=git_config_command --force-debug-title='Setting branch remote origin'
90+
fi
7991

92+
git_config_command="git config --get branch.$current_branch.merge"
93+
run_command --command-in-var=git_config_command --return-var=branch_remote_merge --debug-title="Checking if branch.$current_branch.merge exist in git config"
94+
if [ ! "$branch_remote_merge" ]; then
95+
branch_remote_merge="refs/heads/$current_branch"
96+
println_not_silent "Setting branch remote merge to '$branch_remote_merge'" $gray
97+
git_config_command="git config --add branch.$current_branch.merge $branch_remote_merge"
98+
run_command --command-in-var=git_config_command --force-debug-title='Setting branch remote merge'
99+
fi
100+
}
80101
merge_upstream()
81102
{
82103
if [ "$skip_init_feature" ] && [ ! "$merge" ];then
@@ -186,7 +207,7 @@ init()
186207
fi
187208
printf "${bold}smud $func${normal}: Initializes local repository and sets ${yellow}upstream, origin remotes, source-branch${normal} and ${yellow}default-branch${normal}\n"
188209
printf "${yellow}upstream${normal}: \n"
189-
printf " With Only ${green}$func${normal}, ${yellow}upstream${normal} '${bold}$default_upstream${normal}' will be configured if not configured yet. When configured the upstream will be fetched. \n"
210+
printf " With Only ${green}$func${normal}, ${yellow}upstream-url${normal} '${bold}$default_upstream${normal}' AND ${yellow}upstream${normal} ${bold}'upstream/main'${normal} will be configured if not configured yet. When configured the upstream will be fetched. \n"
190211
printf " With ${green}$func ${bold}<value>${normal}, ${yellow}upstream${normal} '${bold}<value>${normal}' will be configured before upstream is fetched. \n"
191212
printf " With ${green}$func ${bold}${yellow}${bold}--upstream-url <value>${normal}, ${yellow}upstream${normal} '${bold}<value>${normal}' will be configured before upstream is fetched. \n"
192213
printf " With ${green}$func ${yellow}${bold}-${normal}, ${yellow}upstream${normal} will be removed. \n"
@@ -208,8 +229,15 @@ init()
208229
fi
209230
if [ "$skip_init_feature" ];then
210231
return
211-
fi
232+
fi
212233

234+
get_arg list_branches '--list-branches,--list'
235+
if [ "$list_branches" ]; then
236+
echo "Existing git-brances:"
237+
git branch
238+
return
239+
fi
240+
213241
if [ ! "$upstream_url" ]; then
214242
upstream_url="$1"
215243
if [ ! "$upstream_url" ]; then
@@ -248,6 +276,7 @@ init()
248276
fi
249277
fi
250278

279+
set_branch_origin
251280
git__setup_source_config
252281

253282
if [ ! "$remote_origin" ]; then
@@ -261,9 +290,5 @@ init()
261290
if [ "$run_push" ]; then
262291
git_push
263292
fi
264-
265-
if [ "$configs" ]; then
266-
git_config_command="git config -l"
267-
run_command --command-in-var git_config_command --skip-error
268-
fi
293+
show_configs
269294
}

smud-cli/functions-list.sh

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ list()
106106
} || {
107107
return
108108
}
109-
109+
# echo "¤¤¤¤¤ installed: $installed"
110110
if [ "$installed" ]; then
111111
product_infos__find_latest_products_with_version "installed"
112112
product_infos__find_latest_products_with_version "skip-add-new-product"
113113
else
114114
product_infos__find_latest_products_with_version
115115
fi
116116

117-
product_infos__find_latest_products_with_files
117+
# product_infos__find_latest_products_with_files
118118

119119
product_infos__print
120120
}
@@ -335,6 +335,11 @@ product_infos__find_latest_products_with_files()
335335
stage_product_name="$product_name_files/$product_stage"
336336
product_info="${product_infos[${stage_product_name}]}"
337337
if [ ! "$product_info" ]; then
338+
echo "******* Not found product_info: $stage_product_name"
339+
# create_product_info product_info
340+
# product_infos[$stage_product_name]="$product_info"
341+
# product_info="${product_infos[${stage_product_name}]}"
342+
338343
# echo "** find-files : $i: file='$file', stage_product_name='$stage_product_name', NO PRODUCT_INFO -- product_name_files=$product_name_files"
339344
continue
340345
fi
@@ -482,7 +487,9 @@ resolve_team_array()
482487
fi
483488
teams_resolved="true"
484489
fi
485-
490+
# for t in $responsibles; do
491+
# echo "===== TEAM: $t"
492+
# done
486493

487494
}
488495

@@ -657,6 +664,7 @@ product_infos__print()
657664
# fi
658665

659666
if [ "$show_files" ]; then
667+
# echo "product_info: $product_info"
660668
product_info__get_latest_files product_info files
661669
fi
662670

@@ -947,7 +955,7 @@ create_product_info()
947955
fi
948956

949957
createproductinfo__local_product_info="$product_latest_date|$current_version|$product_latest_version|$product_latest_commit|$product_info_files|$product_info_dependencies|$product_responsible"
950-
# echo "create_product_info()...[$product_info_dependencies]"
958+
# echo "create_product_info()...[$createproductinfo__local_product_info]"
951959
}
952960

953961

@@ -1244,30 +1252,47 @@ append_product_depenencies()
12441252

12451253
append_product()
12461254
{
1255+
file_to_append="$1"
1256+
if [ "$file_to_append" ] && [ $(grep "chartVersion:" -c <<< $file_to_append) -gt 0 ]; then
1257+
return
1258+
fi
1259+
12471260
if [ "$4" ];then
12481261
local -n appendproduct__return_value="$4"
12491262
fi
12501263

12511264
appendproduct__return_value="false"
12521265
local product_info_created=0
1266+
12531267
if [ ! "$product_info" ] && [ "$stage_product_name" ]; then
1254-
product_info="${product_infos[${stage_product_name}]}"
1268+
product_info="${product_infos[${stage_product_name}]}"
12551269
if [ ! "$product_info" ];then
12561270
if [ "$3" = "false" ];then
12571271
return
12581272
fi
1273+
# product_info_files=""
1274+
# product_responsible=""
1275+
# product_info_dependencies=""
1276+
# product_latest_version=""
12591277
product_info_created=1
12601278
create_product_info product_info
12611279
product_infos[$stage_product_name]="$product_info"
12621280
appendproduct__return_value="true"
12631281
fi
12641282
fi
1283+
12651284
if [ $product_info_created -eq 0 ]; then
12661285
product_info__get_latest_version product_info product_latest_version
12671286
product_info__get_dependencies product_info product_info_dependencies
12681287
fi
12691288

1270-
file_to_append="$1"
1289+
if [ ! "${product_infos[${stage_product_name}]}" ]; then
1290+
old_product_info=$product_info
1291+
product_info="||||||"
1292+
product_infos[$stage_product_name]=$product_info
1293+
# echo "@@@@@ product: $stage_product_name -- MISSING --- product_info: $product_info"
1294+
# echo "@@@@@ product: $stage_product_name -- MISSING --- old_product_info: $old_product_info"
1295+
fi
12711296

12721297
if [ ! "$file_to_append" ]; then
12731298
return
@@ -1281,6 +1306,8 @@ append_product()
12811306
if [ ! "$file_state_to_append" ]; then
12821307
file_state_to_append="A"
12831308
fi
1309+
1310+
12841311
regex_stage_product_name=$(echo "$stage_product_name" | sed -e 's/\//\\\//g')
12851312
file_to_append=$(echo "$file_to_append"|sed -e "s/products\\/${regex_stage_product_name}\\///g" )
12861313

@@ -1292,6 +1319,10 @@ append_product()
12921319
if [ "$appendproduct__return_value" = "false" ]; then
12931320
appendproduct__return_value="$append_product_appendproductfiles__return_value"
12941321
fi
1322+
1323+
# echo "@@@@@ product: $stage_product_name -- file_to_append: $file_to_append --- appendproduct__return_value: $appendproduct__return_value"
1324+
# echo "@@@@@ product: $stage_product_name -- product_info: ${product_infos[${stage_product_name}]}"
1325+
12951326
}
12961327

12971328

smud-cli/functions-resources.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,19 @@ resources()
2020
pods_command="kubectl get pods ${namespace_filter} ${exclude_ns} --sort-by=.spec.containers[].resources.requests.cpu -o custom-columns=NAME:.metadata.name,${ns_col}REQ-CPU:.spec.containers[].resources.requests.cpu,REQ-MEM:.spec.containers[].resources.requests.memory,INIT-REQ-CPU:.spec.initContainers[].resources.requests.cpu,INIT-REQ-MEM:.spec.initContainers[].resources.requests.memory,OWNER-KIND:.metadata.ownerReferences[].kind,OWNER-NAME:.metadata.ownerReferences[].name |sed -e 's/<none>/ /g'"
2121
cronjobs_command="kubectl get cj ${namespace_filter} --sort-by=.spec.jobTemplate.spec.template.spec.containers[].resources.requests.cpu -o custom-columns=NAME:.metadata.name,${ns_col}REQ-CPU:.spec.jobTemplate.spec.template.spec.containers[].resources.requests.cpu,REQ-MEM:.spec.jobTemplate.spec.template.spec.containers[].resources.requests.memory |sed -e 's/<none>/ /g'"
2222

23-
run_command --command-var=pods_command --return-var=lines_array --array --force-debug-title 'Pod resources'
23+
run_command --command-var=pods_command --return-var=lines_str --skip-shell --force-debug-title 'Pod resources'
24+
2425
old_SEP=$IFS
2526

26-
IFS=$'\n'
27-
if [ ${#lines_array[@]} -gt 1 ]; then
27+
# IFS=$'\n'
28+
read -rd '' -a lines <<< "$lines_str"
29+
# echo ${#lines[@]}:${lines_array[@]}
30+
if [ ${#lines[@]} -gt 1 ]; then
2831
echo "Pods:"
29-
header="${lines_array[0]}"
32+
header="${lines[0]}"
3033
printf "${white}$header${normal}\n"
31-
echo "${lines[@]}" | tail +2|tac
34+
echo "${lines[@]}"
35+
# echo "${lines[@]}" | tail +2|tac
3236
fi
3337

3438
run_command --command-var=cronjobs_command --return-var=cron_lines_array --array --force-debug-title 'Cronjob resources'

smud-cli/functions.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ show_valid_commands()
99
echo " version Show the version-log of smud CLI"
1010
echo " list List products ready for installation or current products installed."
1111
echo " conflict(s) Scan and list conflicts in yaml-files. (Under construction)"
12+
echo " resource(s) Report rescource in use in current kubernetes-cluster"
1213

1314
if [ ! "$is_smud_dev_repo" ]; then
1415
echo " upgrade Upgrade one or more productst to the repository."

0 commit comments

Comments
 (0)