-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheasygit.sh
146 lines (124 loc) · 2.79 KB
/
easygit.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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
# easygit Bash script, by bassandaruwan
# Easy handling of git pull, add, commit and push
# Usage:
# 1. bash easygit.sh -h
# Get help
# 2. bash easygit.sh
# Check git status
# 3. bash easygit.sh 'comment'
# Git add, commit (with comment) and push
# 4. bash easygit.sh -c 'comment'
# Only git add . and commit with 'comment'
# 5. bash easygit.sh -p
# Only git push
echo
echo ===== Easy-Git =====
echo
version_revision() {
today=$(date +"%y%m%d")
file="revision.yaml"
rm -f $file
echo REVISION: $today >>$file
}
if [ $# -gt 0 ]; then
# echo "Method 1"
case "$1" in
-h | --help)
echo "$package - easy git use"
echo " "
echo "options:"
echo "-h, --help show brief help"
echo "-c, Only git add and commit w/ comment"
echo "-p, Only git push"
echo
echo "Usage:
1. bash easygit.sh -h
- Get help
2. bash easygit.sh
- Check git status
3. bash easygit.sh 'comment'
- Git add, commit (with comment) and push
4. bash easygit.sh -c 'comment'
- Only git add . and commit with 'comment'
5. bash easygit.sh -p
- Only git push"
exit 0
;;
-c)
shift
echo "*** Only git add & commit"
echo
# version_revision
if [ $# -eq 1 ]; then
echo ">>" "Commit message:" "$1"
echo
echo
echo ">>" "Checking git status"
echo
git status
echo
echo ">>" "Git add"
echo
git add .
echo
echo ">>" "Git commit"
echo
git commit -m "$1"
else
echo "ERROR: Commit message required"
fi
exit 0
;;
-p)
shift
if [ $# -eq 0 ]; then
echo "*** Only git push"
echo
echo
echo ">> Git push"
echo
git push
else
echo "ERROR: Unnecessary arguments!"
fi
exit 0
;;
esac
fi
if [ $# -eq 0 ]; then
echo
echo ">>" "Checking git status"
echo
git status
exit 0
fi
if [ $# -eq 1 ]; then
# version_revision
echo ">>" "Commit message:" "$1"
echo
echo
echo ">>" "Git pull"
echo
git pull
echo
echo ">>" "Checking git status"
echo
git status
echo
echo ">>" "Git add"
echo
git add .
echo
echo ">>" "Git commit"
echo
git commit -m "$1"
echo
echo ">>" "Git push"
echo
git push
echo
echo ">>" "Checking git status"
echo
git status
fi