Skip to content

Commit

Permalink
Now will list only list changed products ready for upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
aho-dips committed Feb 7, 2024
1 parent ce141d0 commit b5a73da
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
4 changes: 1 addition & 3 deletions smud-cli/functions-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,10 @@ init()
return
fi

upstream_url="${2:-}"

remote_origin=$(git config --get remote.origin.url)
remote_upstream=$(git config --get remote.upstream.url)

if [ ! "$remote_upstream" ]; then
if [ ! "$remote_upstream" ] || [ "$upstream_url" ]; then
if [ ! "$upstream_url" ]; then
upstream_url="$default_upstream"
fi
Expand Down
48 changes: 31 additions & 17 deletions smud-cli/functions-list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,24 @@ list()
product_infos__find_latest_products_with_version()
{
option="$1"

source=""
product_name=""
pos_colon=2
progress_title="latest products with version"
if [ "$option" = "installed" ]; then
progress_title="installed products with version"
commit_filter=""
pos_colon=1
app_files_command="git --no-pager grep 'chartVersion: $version' $commit_filter -- :$app_files_filter|uniq"
else
commit_filter="$to_commit"
source="git"
commit_filter="$git_range"
if [ ! "$commit_filter" ]; then
return
fi
app_files_command="git --no-pager diff $commit_filter --no-merges --pretty=format:'' -- :$filter| grep '+++ .*app.yaml\|+++ .*values.yaml\|+ chartVersion'| sed -e 's/+//g' -e 's/b\///g' | uniq"
fi
app_files_command="git --no-pager grep 'chartVersion: $version' $commit_filter -- :$app_files_filter|uniq"

{
run_command --files --command-var=app_files_command --return-var=changed_files --debug-title='Find all changed app files'
} || {
Expand All @@ -151,8 +154,8 @@ product_infos__find_latest_products_with_version()
product_names=()
fi

app_files_command="git --no-pager grep -B 0 -A 500 'dependencies:' $commit_filter -- :$app_files_filter|sed -e 's/.*:dependencies://g'|uniq"
run_command --files --command-var=app_files_command --return-var=dependencies_files --skip-error --debug-title='Find all dependencies app files'
app_dependecy_command="git --no-pager grep -B 0 -A 500 'dependencies:' $commit_filter -- :$app_files_filter|sed -e 's/.*:dependencies://g'|uniq"
run_command --files --command-var=app_dependecy_command --return-var=dependencies_files --skip-error --debug-title='Find all dependencies app files'
if [ "$dependencies_files" ]; then
IFS=$'\n';read -rd '' -a dependencies_files <<< "$dependencies_files"
fi
Expand All @@ -173,15 +176,20 @@ product_infos__find_latest_products_with_version()
i=0
for line in "${changed_files[@]}"
do
i=$((i+1))
# echo "$i: line=$line"

c=$(expr match $line '.*/app\.yaml')
c2=$(expr match $line '.*/values\.yaml')
if [ $c -gt 0 ] || [ $c2 -gt 0 ]; then
i=$((i+1))
# echo "$i: line=$line"
file="$(echo "$line" | cut -d ':' -f $pos_colon)"
product_name="$(echo "$file" | cut -d '/' -f 2)"
product_stage="$(echo "$file" | cut -d '/' -f 3)"
stage_product_name="$product_name/$product_stage"
fi

progressbar__increase $i "${#product_infos[@]} $progress_title found"

file="$(echo "$line" | cut -d ':' -f $pos_colon)"
product_name="$(echo "$file" | cut -d '/' -f 2)"
product_stage="$(echo "$file" | cut -d '/' -f 3)"
stage_product_name="$product_name/$product_stage"
found_version="$(echo "$line" | cut -d ':' -f $((pos_colon+2))|xargs|sed -e 's/"//g'|xargs|tr -d ['\n','\r'] |cut -d '#' -f 1 |xargs)"
if [[ ! " ${product_names[@]} " =~ " $product_name " ]]; then
if [ "$option" = "skip-add-new-product" ]; then
Expand Down Expand Up @@ -225,6 +233,7 @@ product_infos__find_latest_products_with_version()
append_product "$file" "A" "$add_product"
complete_version
done

if [ "$dependencies_files" ]; then
product_info_dependencies=""
for line in "${dependencies_files[@]}"
Expand All @@ -240,12 +249,15 @@ product_infos__find_latest_products_with_version()
product_name="$(echo "$file" | cut -d '/' -f 2)"
product_stage="$(echo "$file" | cut -d '/' -f 3)"
local stage_product_name="$product_name/$product_stage"
# echo "stage_product_name: $stage_product_name, dependency: $dependency"
append_product_depenencies "$dependency" "$stage_product_name"
# echo "depedencies_return: $depedencies_return"
product_info=${product_infos[$stage_product_name]}
complete_version
# echo "xxx: ${product_infos[$stage_product_name]}"
if [ "$product_info" ];then
# echo "stage_product_name: $stage_product_name, dependency: $dependency"
append_product_depenencies "$dependency" "$stage_product_name"
# echo "depedencies_return: $depedencies_return"
product_info=${product_infos[$stage_product_name]}
complete_version
# echo "xxx: ${product_infos[$stage_product_name]}"
fi
fi
fi
done
Expand Down Expand Up @@ -447,6 +459,7 @@ product_infos__print()
product_info__get_current_version product_info current_version
if [ ! "$current_version" ]; then
get_current_version product_info stage_product_name current_version
# a=1
fi

if [ "$show_latest_version_in_list" = "true" ]; then
Expand All @@ -455,6 +468,7 @@ product_infos__print()
if [ ! "$latest_version" ] && [ "$git_range" ]; then
get_latest_version latest_version
fi

else
latest_version=""
if [ "$product_stage" = "development" ] && [ "$has_internal_test" ]; then
Expand Down Expand Up @@ -862,7 +876,7 @@ get_latest_version()

latest_version_command="git --no-pager grep "chartVersion:" $product_latest_commit_local:$file"
{
run_command --latest_version --command-var=latest_version_command --return-var=getlatestversion__latest_version --debug-title='Find latest versions from conent'
run_command --latest_version --command-var=latest_version_command --return-var=getlatestversion__latest_version --skip-error --debug-title='Find latest versions from conent'
# echo "getlatestversion__latest_version(0): '$getlatestversion__latest_version'"
getlatestversion__latest_version="$(echo "$getlatestversion__latest_version" | cut -d ':' -f 4 | sed -e 's/"//g'|xargs)"
product_latest_version=$getlatestversion__latest_version
Expand Down

0 comments on commit b5a73da

Please sign in to comment.