-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit_builder.sh
More file actions
executable file
·96 lines (83 loc) · 2.62 KB
/
Copy pathcommit_builder.sh
File metadata and controls
executable file
·96 lines (83 loc) · 2.62 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
# Emoji dictionary
declare -A emoji
emoji["Add"]="⭐"
emoji["Refactor"]="⚻"
emoji["Configure"]="⚙"
emoji["Remove"]="💥"
emoji["Test"]="🧪"
emoji["Optimize"]="🚀"
emoji["Document"]="📄"
emoji["Fix"]="🪲"
emoji["Style"]="🎨"
emoji["Celebrate"]="🎉"
# Prompt for Action
read -p "Enter Action (h for help): " action
# If help, show help and exit
if [[ "$action" == "h" ]]; then
echo "Add (a) - ${emoji["Add"]} Add a new file"
echo "Refactor (r) - ${emoji["Refactor"]} Refactor existing code"
echo "Configure (c) - ${emoji["Configure"]} Configure a setting"
echo "Remove (rm) - ${emoji["Remove"]} Remove a file or setting"
echo "Test (t) - ${emoji["Test"]} Add or update tests"
echo "Optimize (o) - ${emoji["Optimize"]} Optimize code"
echo "Document (d) - ${emoji["Document"]} Add or update documentation"
echo "Fix (f) - ${emoji["Fix"]} Fix a bug"
echo "Style (s) - ${emoji["Style"]} Update style"
echo "Celebrate (cl) - ${emoji["Celebrate"]} Celebrate a milestone"
read -p "Enter Action: " action
fi
# Switch action to full name
case $action in
"a") action="Add" ;;
"r") action="Refactor" ;;
"c") action="Configure" ;;
"rm") action="Remove" ;;
"t") action="Test" ;;
"o") action="Optimize" ;;
"d") action="Document" ;;
"f") action="Fix" ;;
"s") action="Style" ;;
"cl") action="Celebrate" ;;
esac
# Check if action is valid
emojiAction=${emoji[$action]}
if [ -z "$emojiAction" ]; then
echo "Invalid action '$action'."
exit 1
fi
# Prompt for Scope
read -p "Enter Scope: " scope
# Prompt for Message
read -p "Enter Message: " message
# If no action or scope, exit
if [ -z "$action" ] || [ -z "$scope" ]; then
echo "No action or scope provided."
exit 1
fi
# If no message, prompt for message
if [ -z "$message" ]; then
read -p "No message included. Do you want to continue without a message? (y/n): " confirm
while [[ "$confirm" != "y" ]] && [[ "$confirm" != "n" ]]; do
read -p "Do you want to continue without a message? (y/n): " confirm
done
if [ "$confirm" != "y" ]; then
read -p "Enter Message: " message
commitMessage="$emojiAction ${scope}: $message"
else
commitMessage="$emojiAction ${scope}"
fi
else
commitMessage="$emojiAction ${scope}: $message"
fi
# Prompt for confirmation
read -p "Commit? ($commitMessage) (y/n): " confirm
while [[ "$confirm" != "y" ]] && [[ "$confirm" != "n" ]]; do
read -p "Commit? (y/n): " confirm
done
# If n, exit
if [ "$confirm" != "y" ]; then
exit 1
fi
# Commit using Git
git commit -m "$commitMessage"