From 617a940cf823917bc86df5f05350236c40560dc0 Mon Sep 17 00:00:00 2001 From: welpo Date: Wed, 24 Jul 2024 20:10:19 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20misc(release):=20ensure=20local?= =?UTF-8?q?=20repository=20is=20in=20good=20state?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- release | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/release b/release index 22ed298bf..8e962089a 100644 --- a/release +++ b/release @@ -11,6 +11,27 @@ if [ -n "$(git status --porcelain)" ]; then exit 1 fi +# Ensure the local repository is up-to-date. +echo "Updating local repository…" +git fetch origin +git_status=$(git status -uno) +if echo "$git_status" | grep -q "Your branch is behind"; then + echo "Your local branch is behind the remote. Please pull the latest changes before running this script." + exit 1 +elif echo "$git_status" | grep -q "Your branch is ahead"; then + echo "Your local branch is ahead of the remote. Attempting to push changes..." + if git push --dry-run 2>&1 | grep -q "Everything up-to-date"; then + echo "Local changes can be pushed without conflicts. Proceeding with the release." + else + echo "Unable to push local changes. Please resolve any conflicts before running this script." + exit 1 + fi +elif ! echo "$git_status" | grep -q "Your branch is up to date"; then + echo "Unable to determine if branch is up to date. Please check your git status manually." + exit 1 +fi +echo "Local repository is ready for release preparation." + # Check if a version tag is provided. if [ "$#" -eq 1 ]; then VERSION_TAG=$1