🧹 chore(full): upgrade script

This commit is contained in:
Eshan Roy (Eshanized)
2024-06-16 23:00:55 +05:30
parent fb873d6a29
commit 5d8e513006

73
push.sh
View File

@@ -1,37 +1,52 @@
#!/bin/bash
# Author : Eshan Roy
# URI : https://eshanized.github.io
# Author : ESHAN ROY
# Author URI : https://eshanized.github.io
# NOTE: If you are on Snigdha OS,
# you can install commitizen-go with `sudo pacman -S commitizen-go`
# or `s commitizen-go`. Else you need to install `yay` or `yay-bin`
# to install commitizen. I have written this script only for *Arch Linux.
# NOTE : Run at your own Risk!
# Function to check if Commitizen is installed
pull_from_github(){
git pull
}
# Define the conventional commit types with emojis
TYPES=("🎉 feat" "🐞 fix" "📚 docs" "💅 style" "🔨 refactor" "⚡️ perf" "🧪 test" "🛠️ build" "🤖 ci" "🧹 chore" "⏪️ revert")
check_commitizen() {
if ! pacman -Qq commitizen-go &> /dev/null; then
echo "Commitizen is not installed. Please install it using 'yay -S commitizen-go'." >&2
exit 1
fi
}
# Prompt the user to select a commit type
echo "Select a commit type:"
select type in "${TYPES[@]}"; do
break
done
# Function to stage, commit, and push changes
push_to_github() {
git add .
git cz
git push origin master
}
# Extract the commit type and emoji from the selection
type_emoji=${type}
type=${type_emoji#* }
emoji=${type_emoji% *}
# Main Function
main() {
pull_from_github
check_commitizen
push_to_github
}
# Prompt the user to enter a scope (optional)
read -p "Enter a scope (optional): " scope
main
# Prompt the user to enter a short description
read -p "Enter a short description: " desc
# Prompt the user to enter a longer description (optional)
read -p "Enter a longer description (optional): " long_desc
# Create the commit message
commit_msg="$emoji $type($scope): $desc"
# If a longer description was provided, add it to the commit message
if [ -n "$long_desc" ]; then
commit_msg+="
$long_desc"
fi
# Print the commit message to the console
echo "Commit message:"
echo "$commit_msg"
# Stage all changes
git add .
# Commit the changes with the conventional commit message
git commit -m "$commit_msg"
# Push the changes to the remote repository
git push origin $(git rev-parse --abbrev-ref HEAD)