Skip to content

Commit

Permalink
👷 misc(release): ensure local repository is in good state
Browse files Browse the repository at this point in the history
  • Loading branch information
welpo committed Jul 24, 2024
1 parent 89d3544 commit 617a940
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions release
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 617a940

Please sign in to comment.