Compare commits
7 Commits
master
...
spike/auto
Author | SHA1 | Date | |
---|---|---|---|
|
1af213a95a | ||
|
0675918362 | ||
|
e8c4946111 | ||
|
086fb11436 | ||
|
e7558cdbe8 | ||
|
c2ea66a87f | ||
|
4eceb41ebc |
@ -1,36 +1,39 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# waits for commits on any branch on origin, checks it out and builds it
|
||||||
|
|
||||||
# get the current branch name
|
. .aliases
|
||||||
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
|
echo "Checking for new commits on any branch ..."
|
||||||
|
git fetch origin
|
||||||
|
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`
|
||||||
|
|
||||||
# get the latest commit hashes from origin and local
|
if [ -n "$branch_with_new_commits" ]; then
|
||||||
git fetch origin
|
echo "checking out branch: $branch_with_new_commits"
|
||||||
LOCAL=$(git rev-parse HEAD)
|
if git show-ref --quiet --heads "$branch_with_new_commits"; then
|
||||||
REMOTE=$(git rev-parse origin/$BRANCH)
|
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
|
||||||
|
|
||||||
# check if the local branch differs from the remote branch
|
echo "building ..."
|
||||||
if [ "$LOCAL" != "$REMOTE" ]; then
|
./gradlew test
|
||||||
echo "local $LOCAL differs from remote $REMOTE => pulling changes from origin"
|
fi
|
||||||
git pull origin $BRANCH
|
|
||||||
|
|
||||||
# run the command
|
# wait 10s with a little animation
|
||||||
echo "Running ./gradlew test"
|
echo -e -n " waiting for changes (/) ..."
|
||||||
source .aliases # only variables, aliases are not expanded in scripts
|
sleep 2
|
||||||
./gradlew test
|
echo -e -n "\r\033[K waiting for changes (-) ..."
|
||||||
fi
|
sleep 2
|
||||||
|
echo -e -n "\r\033[K waiting for changes (\) ..."
|
||||||
# wait 10s with a little animation
|
sleep 2
|
||||||
echo -e -n " waiting for changes (/) ..."
|
echo -e -n "\r\033[K waiting for changes (|) ..."
|
||||||
sleep 2
|
sleep 2
|
||||||
echo -e -n "\r\033[K waiting for changes (-) ..."
|
echo -e -n "\r\033[K waiting for changes ( ) ... "
|
||||||
sleep 2
|
sleep 2
|
||||||
echo -e -n "\r\033[K waiting for changes (\) ..."
|
echo -e -n "\r\033[K checking 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"
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user