handle locally existing branches

This commit is contained in:
Michael Hoennig 2024-09-26 14:20:37 +02:00
parent 0675918362
commit 1af213a95a

View File

@ -10,8 +10,14 @@ while true; do
if [ -n "$branch_with_new_commits" ]; then if [ -n "$branch_with_new_commits" ]; then
echo "checking out branch: $branch_with_new_commits" echo "checking out branch: $branch_with_new_commits"
echo "git checkout -b \"$branch_with_new_commits\" \"origin/$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" git checkout -b "$branch_with_new_commits" "origin/$branch_with_new_commits"
fi
echo "building ..." echo "building ..."
./gradlew test ./gradlew test