2024-09-16 15:36:37 +02:00
|
|
|
#!/bin/bash
|
2024-09-26 13:59:13 +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-09-26 14:12:03 +02:00
|
|
|
. .aliases
|
2024-09-26 12:04:41 +02:00
|
|
|
|
2024-09-16 15:36:37 +02:00
|
|
|
while true; do
|
2024-09-26 13:59:13 +02:00
|
|
|
echo "Checking for new commits on any branch ..."
|
2024-09-26 12:04:41 +02:00
|
|
|
git fetch origin
|
2024-09-26 13:59:13 +02:00
|
|
|
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-26 12:04:41 +02:00
|
|
|
|
2024-09-26 13:59:13 +02:00
|
|
|
if [ -n "$branch_with_new_commits" ]; then
|
|
|
|
echo "checking out branch: $branch_with_new_commits"
|
2024-09-26 14:09:44 +02:00
|
|
|
echo "git checkout -b \"$branch_with_new_commits\" \"origin/$branch_with_new_commits\""
|
2024-09-26 13:59:13 +02:00
|
|
|
git checkout -b "$branch_with_new_commits" "origin/$branch_with_new_commits"
|
2024-09-26 12:04:41 +02:00
|
|
|
|
2024-09-26 13:59:13 +02:00
|
|
|
echo "building ..."
|
2024-09-26 14:12:03 +02:00
|
|
|
./gradlew test
|
2024-09-26 12:04:41 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# wait 10s with a little animation
|
2024-09-26 13:59:13 +02:00
|
|
|
echo -e -n " 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-09-26 12:04:41 +02:00
|
|
|
|