Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update generation script to handle non-versioned items #460

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions .ci/generate_last_mod_file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -48,21 +53,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 == "undefined" ]]; 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) undefined \(.git.revision) \(.git.remotes.origin)"
else
"\(.name) undefined undefined \(.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() {
Expand Down
Loading