2024-09-16 15:36:37 +02:00
|
|
|
#!/bin/bash
|
2024-10-09 19:19:11 +02:00
|
|
|
# waits for commits on any branch on origin, checks it out and builds it
|
2024-09-16 15:36:37 +02:00
|
|
|
|
2024-10-09 19:19:11 +02:00
|
|
|
. .aliases
|
2024-09-16 15:36:37 +02:00
|
|
|
|
|
|
|
while true; do
|
2024-10-09 19:19:11 +02:00
|
|
|
git fetch origin >/dev/null
|
|
|
|
branch_with_new_commits=`git fetch origin >/dev/null; git for-each-ref --format='%(refname:short) %(upstream:track)' refs/heads | grep '\[behind' | cut -d' ' -f1 | head -n1`
|
2024-09-16 15:36:37 +02:00
|
|
|
|
2024-10-09 19:19:11 +02:00
|
|
|
if [ -n "$branch_with_new_commits" ]; then
|
|
|
|
echo "checking out branch: $branch_with_new_commits"
|
|
|
|
if git show-ref --quiet --heads "$branch_with_new_commits"; then
|
|
|
|
echo "Branch $branch_with_new_commits already exists. Checking it out and pulling latest changes."
|
|
|
|
git checkout "$branch_with_new_commits"
|
|
|
|
git pull origin "$branch_with_new_commits"
|
|
|
|
else
|
|
|
|
echo "Creating and checking out new branch: $branch_with_new_commits"
|
|
|
|
git checkout -b "$branch_with_new_commits" "origin/$branch_with_new_commits"
|
|
|
|
fi
|
2024-09-16 15:36:37 +02:00
|
|
|
|
2024-10-09 19:19:11 +02:00
|
|
|
echo "building ..."
|
|
|
|
./gradlew gw clean test check -x pitest
|
|
|
|
fi
|
2024-09-16 15:36:37 +02:00
|
|
|
|
2024-10-09 19:19:11 +02:00
|
|
|
# wait 10s with a little animation
|
|
|
|
echo -e -n "\r\033[K waiting for changes (/) ..."
|
|
|
|
sleep 2
|
|
|
|
echo -e -n "\r\033[K waiting for changes (-) ..."
|
|
|
|
sleep 2
|
|
|
|
echo -e -n "\r\033[K waiting for changes (\) ..."
|
|
|
|
sleep 2
|
|
|
|
echo -e -n "\r\033[K waiting for changes (|) ..."
|
|
|
|
sleep 2
|
|
|
|
echo -e -n "\r\033[K waiting for changes ( ) ... "
|
|
|
|
sleep 2
|
|
|
|
echo -e -n "\r\033[K checking for changes"
|
2024-09-16 15:36:37 +02:00
|
|
|
done
|
2024-10-09 19:19:11 +02:00
|
|
|
|