-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit_auto
executable file
·44 lines (38 loc) · 995 Bytes
/
git_auto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: $0 \"commit_message\" branch_name"
exit 1
fi
commit_message="$1"
branch="$2"
npm run build
git add .
git commit -m "$commit_message"
while true; do
printf "\n"
printf "[1] Confirm\n[2] Change commit\n"
read -p "Enter your choice? (1: Default)" choice
printf "\n"
choice=${choice:-1} # Set default choice to 1 if Enter is pressed
case $choice in
1)
echo "Pushing changes to the $branch branch..."
git push origin $branch
echo "✔ Build and push completed successfully!"
break
;;
2)
read -p "Enter new commit message: " new_commit_message
if [ -z "$new_commit_message" ]; then
echo "Commit message cannot be empty. Exiting."
exit 1
fi
git commit --amend -m "$new_commit_message"
;;
*)
echo "Invalid choice. Please enter 1 or 2."
;;
esac
done