watch all branches for changes
This commit is contained in:
parent
cb4aecb9c8
commit
4eceb41ebc
@ -1,36 +1,52 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# get the current branch name
|
# Configuration: Set the remote repository name and check interval
|
||||||
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
BUILD_CMD="gw-test" # Placeholder for the build command
|
||||||
|
|
||||||
|
# Fetch the latest updates from the origin
|
||||||
|
git fetch origin
|
||||||
|
|
||||||
|
# Keep track of local branches at the start
|
||||||
|
local_branches=$(git branch -r | sed 's/origin\///')
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
|
echo "Checking for new branches..."
|
||||||
|
|
||||||
# get the latest commit hashes from origin and local
|
# Fetch the latest updates from the origin
|
||||||
git fetch origin
|
git fetch origin
|
||||||
LOCAL=$(git rev-parse HEAD)
|
|
||||||
REMOTE=$(git rev-parse origin/$BRANCH)
|
|
||||||
|
|
||||||
# check if the local branch differs from the remote branch
|
# List the remote branches after fetching and compare with local branches
|
||||||
if [ "$LOCAL" != "$REMOTE" ]; then
|
new_branches=$(git branch -r | sed 's/origin\///' | grep -Fxv "$local_branches")
|
||||||
echo "local $LOCAL differs from remote $REMOTE => pulling changes from origin"
|
|
||||||
git pull origin $BRANCH
|
|
||||||
|
|
||||||
# run the command
|
if [ -n "$new_branches" ]; then
|
||||||
echo "Running ./gradlew test"
|
for branch in $new_branches; do
|
||||||
source .aliases # only variables, aliases are not expanded in scripts
|
echo "New branch detected: $branch"
|
||||||
./gradlew test
|
|
||||||
fi
|
|
||||||
|
|
||||||
# wait 10s with a little animation
|
# Check out the new branch locally
|
||||||
echo -e -n " waiting for changes (/) ..."
|
git checkout -b "$branch" "origin/$branch"
|
||||||
sleep 2
|
|
||||||
echo -e -n "\r\033[K waiting for changes (-) ..."
|
# Placeholder for build process (replace $BUILD_CMD with actual build steps)
|
||||||
sleep 2
|
echo "Building branch $branch..."
|
||||||
echo -e -n "\r\033[K waiting for changes (\) ..."
|
# eval "$BUILD_CMD"
|
||||||
sleep 2
|
|
||||||
echo -e -n "\r\033[K waiting for changes (|) ..."
|
# Update the local branch list
|
||||||
sleep 2
|
local_branches="$local_branches $branch"
|
||||||
echo -e -n "\r\033[K waiting for changes ( ) ... "
|
done
|
||||||
sleep 2
|
else
|
||||||
echo -e -n "\r\033[K"
|
echo "No new branches found."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# wait 10s with a little animation
|
||||||
|
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"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user