hs.hsadmin.ng/bin/git-pull-and-if-origin-changed-run-tests
2024-09-16 08:47:42 +02:00

29 lines
699 B
Bash
Executable File

#!/bin/bash
# get the current branch name
BRANCH=$(git rev-parse --abbrev-ref HEAD)
while true; do
# get the latest commit hashes from origin and local
git fetch origin
LOCAL=$(git rev-parse HEAD)
REMOTE=$(git rev-parse origin/$BRANCH)
# check if the local branch differs from the remote branch
if [ "$LOCAL" == "$REMOTE" ]; then
echo "pulling changes from origin"
git pull origin $BRANCH
# run the command
echo "Running ./gradlew test"
source .aliases # only variables, aliases are not expanded in scripts
./gradlew test
else
echo "no changes detected on the origin branch"
fi
echo "waiting for 1 minute before checking again..."
sleep 60
done