-
Notifications
You must be signed in to change notification settings - Fork 0
/
push-with-shell.sh
50 lines (43 loc) · 1.25 KB
/
push-with-shell.sh
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
45
46
47
48
49
50
#!/bin/sh
branch_file=".last_branch"
if [ -f "$branch_file" ]; then
branch=$(cat "$branch_file")
else
# prompt the user to enter the branch name
echo "Please enter the branch name:"
read branch
# save the branch name to the branch file
echo "$branch" > "$branch_file"
fi
echo "Please choose a commit message:"
echo "1) 🐛 Fixing bugs"
echo "2) ✨ Adding new feature"
echo "3) ⚡ Refactoring code"
echo "4) 🎨 Custom"
read choice
case $choice in
1) echo "Please enter a description:"; read description; commit_message=":bug: fix: $description";;
2) echo "Please enter a description:"; read description; commit_message=":sparkles: feat: $description";;
3) echo "Please enter a description:"; read description; commit_message=":zap: refactor: $description";;
4) echo "Please enter a commit message:"; read commit_message;;
*) echo "Invalid choice"; exit 1;;
esac
git add .
git commit -m "$commit_message"
read -r -p "Sync Changes?[Y/n]" input
case $input in
[yY][eE][sS]|[yY])
echo "Syncing..."
git pull origin $branch
git push origin $branch
;;
[nN][oO]|[nN])
echo "Exit"
exit 1
;;
*)
echo "Invalid input"
exit 1
;;
esac
echo "$branch" > "$branch_file"