From c25b838efb0624e35642c4dc2aeb9e7e8b4678fd Mon Sep 17 00:00:00 2001 From: eshanized Date: Mon, 6 Jan 2025 23:35:39 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=AC=20test:=20new=20test=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- push.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/push.sh b/push.sh index cf80693f..27873cfd 100755 --- a/push.sh +++ b/push.sh @@ -6,7 +6,7 @@ # Define the conventional commit types with new emojis TYPES=("๐Ÿš€ feat" "๐Ÿ› fix" "๐Ÿ“ docs" "โœจ style" "๐Ÿ›  refactor" "โšก๏ธ perf" "๐Ÿ”ฌ test" "๐Ÿ”ง build" "๐Ÿค– ci" "๐Ÿงน chore" "โช revert") -# Function to display an error and exit and +# Function to display an error and exit error_exit() { echo -e "\033[1;31m[ERROR]\033[0m $1" exit 1 @@ -22,6 +22,11 @@ branch=$(git rev-parse --abbrev-ref HEAD) echo "Pulling latest changes from remote branch '$branch'..." git pull origin "$branch" || error_exit "Failed to pull changes from the remote repository. Please resolve any conflicts manually." +# Check if there are changes to commit +if git diff --quiet && git diff --cached --quiet; then + error_exit "No changes detected to commit." +fi + # Prompt the user to select a commit type echo "Select a commit type:" select type in "${TYPES[@]}"; do @@ -65,7 +70,7 @@ git add . if git commit -m "$commit_msg"; then echo -e "\033[1;32mCommit successful!\033[0m" else - error_exit "Commit failed." + error_exit "Commit failed. Please check your changes and try again." fi # Push the changes to the remote repository @@ -74,4 +79,4 @@ if git push origin "$branch"; then echo -e "\033[1;32mChanges pushed to remote branch '$branch'.\033[0m" else error_exit "Push failed. Please check your connection or branch permissions." -fi \ No newline at end of file +fi