-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitscript.sh
125 lines (117 loc) · 4.21 KB
/
gitscript.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
# ************************************************************************************************** #
# #
# ::: :::::::: :::::::: ::::::::::: #
# gitscript.sh :+:+: :+: :+: :+: :+: :+: :+: #
# +:+ +:+ +:+ +:+ #
# By: ahjadani <ahjadani@student.1337.ma> +#+ +#++: +#++: +#+ #
# +#+ +#+ +#+ +#+ #
# Created: 2022/03/02 13:09:33 by ahjadani #+# #+# #+# #+# #+# #+# #
# Updated: 2022/03/28 10:29:57 by ahjadani ####### ######## ######## ###.ma #
# #
# ************************************************************************************************** #
echo " _____ _____ _______ _____ _____ _____ _____ _____ _______
/ ____|_ _|__ __| / ____|/ ____| __ \|_ _| __ \__ __|
| | __ | | | | | (___ | | | |__) | | | | |__) | | |
| | |_ | | | | | \___ \| | | _ / | | | ___/ | |
| |__| |_| |_ | | ____) | |____| | \ \ _| |_| | | |
\_____|_____| |_| |_____/ \_____|_| \_\_____|_| |_| "
echo ""
echo "[ 1 ] Automatic push every N seconds with random commit message"
echo "[ 2 ] Normal push with specific commit message"
echo "[ 3 ] Push whenever you change something in the code"
cmsg=$(curl -s http://whatthecommit.com/index.txt)
echo $(printf "\e[31m Select an option: \e[0m")
listfile ()
{
python3 -c "$(curl -fsSL https://gist.githubusercontent.com/0xPacman/e9a669bd1fb9c17477370462977c3009/raw/12e9d9a0e92cccaa5af599868156afbfb48ef529/list.py)"
}
read n
if [ $n -eq 1 ]; then
echo "Select the files to track: (type /list to list all files)"
read files
if [ "$files" = "/list" ]; then
listfile
echo "Select the files to track:"
read files
fi
check=$(ls $files | wc -l | xargs)
if [ $check -eq 0 ]; then
echo "Error!"
exit
fi
echo "Push every N seconds:"
echo -n "N: "
read nsec
while [ 1 ]
do
git add $files
check=$(ls $files | wc -l | xargs)
if [ $check -eq 0 ]; then
echo "Error!"
exit
fi
git commit -m "$cmsg"
git push
sleep $nmin
done
elif [ $n -eq 2 ]; then
echo "Select the files to track: (type /list to list all files)"
read files
if [ "$files" = "/list" ]; then
listfile
echo "Select the files to track:"
read files
fi
check=$(ls $files | wc -l | xargs)
if [ $check -eq 0 ]; then
echo "Error!"
exit
fi
while [ 1 ]
do
echo "Commit message: "
read msgcommit
git add $files
git commit -m "$msgcommit"
git push
done
elif [ $n -eq 3 ]; then
echo "Select the files to track: (type /list to list all files)"
read files
if [ "$files" = "/list" ]; then
listfile
echo "Select the files to track:"
read files
fi
check=$(ls $files | wc -l | xargs)
if [ $check -eq 0 ]; then
echo "Error!"
exit
fi
if [[ "$OSTYPE" == "darwin"* ]]; then
ls -laT $files | awk '{print $8}' > .git_script
else
ls -la --full-time $files | awk '{print $7}' > .git_script
fi
while [ 1 ]
do
if [[ "$OSTYPE" == "darwin"* ]]; then
ls -laT $files | awk '{print $8}' > .git_script_2
else
ls -la --full-time $files | awk '{print $7}' > .git_script_2
fi
diff .git_script .git_script_2
if [ $? -eq 1 ]; then
if [[ "$OSTYPE" == "darwin"* ]]; then
ls -laT $files | awk '{print $8}' > .git_script
else
ls -la --full-time $files | awk '{print $7}' > .git_script
fi
git add $files
git commit -m "$cmsg"
git push
fi
done
else
echo "Error!"
fi