#!/bin/bash
set -xeuo pipefail
git checkout -b new-quarkus-next origin/main
if ! grep -q '' pom.xml; then
sed -i '/<\/project>/i \
\
' pom.xml
fi
# Insert the element before the closing tag
sed -i '/<\/repositories>/i \
\
sonatype-snapshots \
Sonatype Snapshots \
https://s01.oss.sonatype.org/content/repositories/snapshots/ \
\
true \
daily \
\
\
false \
\
' pom.xml
./mvnw -B versions:set-property -Dproperty=quarkus.version -DnewVersion=999-SNAPSHOT
./mvnw -B versions:set-property -Dproperty=quarkus.build.version -DnewVersion=999-SNAPSHOT
git commit -am "Set quarkus version to 999-SNAPSHOT"
snapshot_version_hash=$(git log origin/quarkus-next --grep="Set quarkus version to 999-SNAPSHOT" --format="%H" -n 1)
commits_to_cherry_pick=$(git rev-list --right-only --no-merges --reverse new-quarkus-next...origin/quarkus-next | grep -vE "$snapshot_version_hash" || echo "")
if [ -z "$commits_to_cherry_pick" ]; then
echo "Nothing to cherry-pick."
else
for commit in $commits_to_cherry_pick
do
if git cherry-pick "$commit"; then
echo "Successfully cherry-picked $commit"
else
echo "Failed to cherry-pick $commit"
exit 1
fi
done
fi