mirror of
https://github.com/Snigdha-OS/snigdhaos-arctic.git
synced 2025-09-20 19:45:01 +02:00
[refactor] enhancement
This commit is contained in:
59
push.sh
59
push.sh
@@ -1,32 +1,41 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Author : Eshan Roy
|
# Stage all changes
|
||||||
# URI : https://eshanized.github.io
|
git add .
|
||||||
|
|
||||||
# NOTE: If you are on Snigdha OS,
|
# Define the conventional commit types
|
||||||
# you can install commitizen-go with `sudo pacman -S commitizen-go`
|
TYPES=("feat" "fix" "docs" "style" "refactor" "perf" "test" "build" "ci" "chore" "revert")
|
||||||
# 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.
|
|
||||||
|
|
||||||
# Function to check if Commitizen is installed
|
# Prompt the user to select a commit type
|
||||||
check_commitizen() {
|
echo "Select a commit type:"
|
||||||
if ! pacman -Qq commitizen-go &> /dev/null; then
|
select type in "${TYPES[@]}"; do
|
||||||
echo "Commitizen is not installed. Please install it using 'yay -S commitizen-go'." >&2
|
break
|
||||||
exit 1
|
done
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to stage, commit, and push changes
|
# Prompt the user to enter a short description
|
||||||
push_to_github() {
|
read -p "Enter a short description: " desc
|
||||||
git add .
|
|
||||||
git cz
|
|
||||||
git push origin master
|
|
||||||
}
|
|
||||||
|
|
||||||
# Main Function
|
# Prompt the user to enter a longer description (optional)
|
||||||
main() {
|
read -p "Enter a longer description (optional): " long_desc
|
||||||
check_commitizen
|
|
||||||
push_to_github
|
|
||||||
}
|
|
||||||
|
|
||||||
main
|
# Create the commit message
|
||||||
|
commit_msg="[$type] $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"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 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)
|
Reference in New Issue
Block a user