From 82f7a984d54046a4f884461b3c5f52ac830661bf Mon Sep 17 00:00:00 2001 From: welpo Date: Wed, 24 Jul 2024 20:25:36 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20misc(release):=20ensure=20script?= =?UTF-8?q?=20is=20ran=20from=20default=20branch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- release | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/release b/release index 32762b688..f8fc9d890 100644 --- a/release +++ b/release @@ -10,6 +10,13 @@ exit_with_message() { exit 1 } +# Run only from default branch. +default_branch=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p') +current_branch=$(git rev-parse --abbrev-ref HEAD) +if [ "$current_branch" != "$default_branch" ]; then + exit_with_message "Not on $default_branch branch. Switch to $default_branch before running this script." +fi + # Check for a clean working directory. if [ -n "$(git status --porcelain)" ]; then exit_with_message "Your working directory is dirty. Commit or stash your changes before running this script."