2023-06-18 15:50:55 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
|
|
set -o nounset # disallow usage of unset vars ( set -u )
|
|
|
|
set -o errexit # Exit immediately if a pipeline returns non-zero. ( set -e )
|
|
|
|
set -o errtrace # Allow the above trap be inherited by all functions in the script. ( set -E )
|
|
|
|
set -o pipefail # Return value of a pipeline is the value of the last (rightmost) command to exit with a non-zero status
|
|
|
|
IFS=$'\n\t' # Set $IFS to only newline and tab.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dir="/tmp/mongo_repo_$( uuidgen )"
|
|
|
|
|
2023-06-18 16:04:34 +02:00
|
|
|
echo ""
|
|
|
|
echo "> Clone https://github.dev/mongodb/mongo-go-driver"
|
|
|
|
echo ""
|
|
|
|
|
2023-06-18 15:50:55 +02:00
|
|
|
git clone "https://github.com/mongodb/mongo-go-driver" "$dir"
|
|
|
|
|
|
|
|
pushd "$dir"
|
|
|
|
|
|
|
|
git fetch --tags
|
|
|
|
|
|
|
|
latestTag="$( git describe --tags `git rev-list --tags --max-count=1` )"
|
|
|
|
|
|
|
|
git -c "advice.detachedHead=false" checkout $latestTag
|
|
|
|
|
|
|
|
latestSHA="$( git rev-parse HEAD )"
|
|
|
|
|
|
|
|
popd
|
|
|
|
|
|
|
|
existingTag=$( cat mongoPatchVersion.go | grep -oP "(?<=const MongoCloneTag = \")([A-Za-z0-9.]+)(?=\")" )
|
|
|
|
existingSHA=$( cat mongoPatchVersion.go | grep -oP "(?<=const MongoCloneCommit = \")([A-Za-z0-9.]+)(?=\")" )
|
|
|
|
|
|
|
|
echo "===================================="
|
|
|
|
echo "ID (online) $latestSHA"
|
|
|
|
echo "ID (local) $existingSHA"
|
|
|
|
echo "Tag (online) $latestTag"
|
|
|
|
echo "Tag (local) $existingTag"
|
|
|
|
echo "===================================="
|
|
|
|
|
|
|
|
if [[ "$latestTag" == "$existingTag" ]]; then
|
|
|
|
echo "Nothing to do"
|
|
|
|
rm -rf "$dir"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2023-06-18 16:04:34 +02:00
|
|
|
echo ""
|
|
|
|
echo "> Copy repository"
|
|
|
|
echo ""
|
|
|
|
|
2023-06-18 15:50:55 +02:00
|
|
|
rm -rf mongo
|
|
|
|
cp -r "$dir" "mongo"
|
2023-06-18 16:04:34 +02:00
|
|
|
rm -rf "$dir"
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "> Clean repository"
|
|
|
|
echo ""
|
|
|
|
|
2023-06-18 15:50:55 +02:00
|
|
|
rm -rf "mongo/.git"
|
|
|
|
rm -rf "mongo/.evergreen"
|
|
|
|
rm -rf "mongo/cmd"
|
|
|
|
rm -rf "mongo/docs"
|
|
|
|
rm -rf "mongo/etc"
|
|
|
|
rm -rf "mongo/examples"
|
|
|
|
rm -rf "mongo/testdata"
|
|
|
|
rm -rf "mongo/benchmark"
|
|
|
|
rm -rf "mongo/vendor"
|
2023-06-19 10:12:40 +02:00
|
|
|
rm -rf "mongo/internal/test"
|
2023-06-18 15:50:55 +02:00
|
|
|
rm -rf "mongo/go.mod"
|
|
|
|
rm -rf "mongo/go.sum"
|
|
|
|
|
2023-06-18 16:04:34 +02:00
|
|
|
echo ""
|
|
|
|
echo "> Update mongoPatchVersion.go"
|
|
|
|
echo ""
|
|
|
|
|
2023-06-18 15:50:55 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
printf "package goext\n"
|
|
|
|
printf "\n"
|
|
|
|
printf "// %s\n" "$( date +"%Y-%m-%d %H:%M:%S%z" )"
|
|
|
|
printf "\n"
|
|
|
|
printf "const MongoCloneTag = \"%s\"\n" "$latestTag"
|
|
|
|
printf "const MongoCloneCommit = \"%s\"\n" "$latestSHA"
|
|
|
|
|
|
|
|
} > mongoPatchVersion.go
|
|
|
|
|
2023-06-18 16:04:34 +02:00
|
|
|
echo ""
|
|
|
|
echo "> Patch mongo"
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
git apply -v _data/mongo.patch
|
2023-06-18 15:50:55 +02:00
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "Done."
|