-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitPush.sh
83 lines (78 loc) · 1.93 KB
/
.gitPush.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
#!/bin/bash
usage() {
echo "optional arguments:
-h, --help Display Menu
-p pull and not push
-f force the command
-t auto add time to the commit
-d run in dev mode (will print)
-a commmit -am insted of commit -m
??? all string send will be the commit name
" 1>&2
exit 1
}
while true; do
case "$1" in
-d)
devmode=true
if [ $devmode ]; then echo $1; fi
shift
;;
-a)
a='a'
if [ $devmode ]; then echo $1; fi
shift
;;
-f)
force=true
if [ $devmode ]; then echo $1; fi
shift
;;
-t)
autoDate=true
if [ $devmode ]; then echo $1; fi
shift
;;
-p)
pull=true
if [ $devmode ]; then echo $1; fi
shift
;;
-h)
usage
;;
*)
if [ $devmode ]; then echo $1; fi
if ! [ -z "$1" ]; then
if [ ${1:0:1} == '-' ]; then
echo "wrong use"
usage
fi
commit=$1
shift
else
break
fi
;;
esac
done
if [ $devmode ]; then echo "force=$force pull=$pull commit=$commit"; fi
gitPush() {
# if [ -n "$(git status - porcelain)" ];
# then
# echo "IT IS CLEAN"
# return
# fi
branch=$(git branch --show-current)
command="push"
if [ $force ]; then force=" -f"; fi
if ! [ "$commit" ]; then commit="auto-commit"; fi
if [ $autoDate ]; then commit+=' '$(date); fi
if [ $pull ]; then command="pull"; fi
if [ $devmode ]; then echo "force=$force pull=$pull commit=$commit branch=$branch commit-type=-"$a"m"; fi
echo "git $command$force origin $branch"
git add .
git commit -"$a"m "$commit"
git $command$force origin $branch
}
gitPush