-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommit.sh
More file actions
executable file
·49 lines (44 loc) · 874 Bytes
/
commit.sh
File metadata and controls
executable file
·49 lines (44 loc) · 874 Bytes
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
#!/bin/sh
# BOJ : ./commit.sh b "$2" "$3"
# Programmers : ./commit.sh p "$2"
date=$(date '+%y_%m_%d')
message=""
flag=0
boj() {
message="BOJ_$1_$date"
}
programmers() {
message="PROGMS_$1($2)_$date"
}
if [ "$1" = "b" ]
then
if [ "$2" = "" ]
then
message="usage: ./commit.sh b <problem_name>"
else
boj "$2"
flag=1
fi
elif [ "$1" = "p" ]
then
if [ "$2" = "" ] || [ "$3" = "" ]
then
message="usage: ./commit.sh p <problem_name> <extension>"
else
programmers "$2" "$3"
flag=1
fi
else
message="usage: ./commit.sh <b|p> <problem_name> [<extension>]"
fi
if [ $flag -eq 0 ]
then
# print error message with red color
echo "\033[31m$message\033[0m"
exit 1
else
git add .
git commit -m "$message"
echo "Successfully committed with message: $message"
exit 0
fi