From daf1a384e2b5fcb6fd9b99b122362f15a579f178 Mon Sep 17 00:00:00 2001 From: Jordan Dubrick Date: Mon, 29 Jul 2024 14:39:37 -0400 Subject: [PATCH 1/2] update generation script to handle non-versioned items Signed-off-by: Jordan Dubrick --- .ci/generate_last_mod_file.sh | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/.ci/generate_last_mod_file.sh b/.ci/generate_last_mod_file.sh index 58cb7c13..95388518 100755 --- a/.ci/generate_last_mod_file.sh +++ b/.ci/generate_last_mod_file.sh @@ -48,21 +48,38 @@ grab_samples(){ version=$(echo "$line" | cut -d ' ' -f 2) revision=$(echo "$line" | cut -d ' ' -f 3) git_origin=$(echo "$line" | cut -d ' ' -f 4) - repo_name="$name"-"$revision" - - git clone -q -b $revision $git_origin $repo_name + if [[ $revision == "null" ]]; then + repo_name="$name" + git clone -q $git_origin $repo_name + else + repo_name="$name"-"$revision" + git clone -q -b $revision $git_origin $repo_name + fi + cd $repo_name last_commit=$(git log -1 --format="%aI") cd $TEMP_DIR sample_data+=("{\"name\": \"${name}\",\"version\": \"${version}\",\"lastModified\": \"${last_commit}\"}") - done < <(jq -r '.samples[] | "\(.name) \(.versions[] | "\(.version) \(.git.revision) \(.git.remotes.origin)")"' $PARENT_DIR/data.json) + done < <(jq -r ' + .samples[] | + if has("versions") + then + "\(.name) \(.versions[] | "\(.version) \(.git.revision) \(.git.remotes.origin)")" + elif .git.revision != null + then + "\(.name) null \(.git.revision) \(.git.remotes.origin)" + else + "\(.name) null null \(.git.remotes.origin)" + end + ' $PARENT_DIR/data.json) + cd $PARENT_DIR # cleanup of temp files and temp data store echo "Cleaning up temp files" rm -rf $PARENT_DIR/temp rm $PARENT_DIR/data.json - + } create_last_modified_file() { From 8c081bd6cd85d67b2a42edb3512e313450a8effa Mon Sep 17 00:00:00 2001 From: Jordan Dubrick Date: Tue, 30 Jul 2024 11:11:47 -0400 Subject: [PATCH 2/2] replace null with undefined Signed-off-by: Jordan Dubrick --- .ci/generate_last_mod_file.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.ci/generate_last_mod_file.sh b/.ci/generate_last_mod_file.sh index 95388518..d740cac8 100755 --- a/.ci/generate_last_mod_file.sh +++ b/.ci/generate_last_mod_file.sh @@ -30,6 +30,11 @@ grab_stacks() { # last commit that modified the entire directory that contains a devfile last_commit=$(git log -1 --format="%aI" -- "$directory") + # replace null -> undefined for consistency with sample handling + if [[ $version == "null" ]]; then + version="undefined" + fi + stack_data+=("{\"name\": \"${stack}\",\"version\": \"${version}\",\"lastModified\": \"${last_commit}\"}") fi done @@ -48,7 +53,7 @@ grab_samples(){ version=$(echo "$line" | cut -d ' ' -f 2) revision=$(echo "$line" | cut -d ' ' -f 3) git_origin=$(echo "$line" | cut -d ' ' -f 4) - if [[ $revision == "null" ]]; then + if [[ $revision == "undefined" ]]; then repo_name="$name" git clone -q $git_origin $repo_name else @@ -67,9 +72,9 @@ grab_samples(){ "\(.name) \(.versions[] | "\(.version) \(.git.revision) \(.git.remotes.origin)")" elif .git.revision != null then - "\(.name) null \(.git.revision) \(.git.remotes.origin)" + "\(.name) undefined \(.git.revision) \(.git.remotes.origin)" else - "\(.name) null null \(.git.remotes.origin)" + "\(.name) undefined undefined \(.git.remotes.origin)" end ' $PARENT_DIR/data.json)