Skip to content

Commit

Permalink
PMM-12899 add directory verification
Browse files Browse the repository at this point in the history
  • Loading branch information
ademidoff committed Mar 20, 2024
1 parent b715e40 commit bb728ea
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion build/local/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,40 @@ rewind() {
fi
}

check-files() {
local DIR="$1"

test -z "DIR" && exit 1

if [ -d "$DIR/sources" ] && [ -f "$DIR/ci-default.yml" ] && [ -f "$DIR/ci.yml" ]; then
return 0
fi

return 1
}

main() {
local DEPS=
local CURDIR="$PWD"
local DIR=pmm-submodules

# Thouroughly verify the presence of known files, otherwise bail out
if check-files "."; then # pwd is pmm-submodules
DIR="."
elif [ -d "$DIR" ]; then # pwd is outside pmm-submodules
if ! check-files "$DIR"; then
echo "FATAL: could not locate known files in ${PWD}/${DIR}"
exit 1
fi
else
echo "FATAL: could not locate known files in $PWD"
exit 1
fi

cd "$DIR"

# Join the dependencies from ci-default.yml and ci.yml
local DEPS=$(yq -o=json eval-all '. as $item ireduce ({}; . *d $item )' ci-default.yml ci.yml | jq '.deps')
DEPS=$(yq -o=json eval-all '. as $item ireduce ({}; . *d $item )' ci-default.yml ci.yml | jq '.deps')

echo "This script rewinds submodule branches as per the joint config of 'ci-default.yml' and 'ci.yml'"

Expand All @@ -63,6 +94,8 @@ main() {
echo
echo "Printing git submodule status..."
git submodule status

cd "$CURDIR" > /dev/null
}

main

0 comments on commit bb728ea

Please sign in to comment.