forked from demon90s/CppStudy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommit.sh
executable file
·74 lines (60 loc) · 931 Bytes
/
commit.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
#! /bin/bash
# 提交代码到github
get_all_dir() {
all_files=`ls`
for f in $all_files; do
if [ -d $f ]; then
echo -e "$f \c"
fi
done
}
clear_build() {
all_dir=$(get_all_dir)
for d in $all_dir; do
cd $d
if [ -f build.sh ]; then
sh build.sh clear
elif [ -f Makefile ]; then
make clean
fi
cd ..
done
cd labs
sh build.sh clear
cd ..
}
show_status() {
if git status | grep 'nothing to commit'; then
return 1
else
echo "Changed files: "
git status -s -u
return 0
fi
}
commit() {
git add -f *
git commit -m "commit"
echo "Committing ..."
git push origin master
}
main() {
clear_build
rm -rf site
if [ "$1" = "gen" ]; then
sh ./gen_readme.sh
cd ./defined_terms
sh ./gen_index.sh
cd ..
fi
if ! show_status; then
return 0
fi
echo -e "--------------------------\nIs it ok [y/n]: \c"
read answer
if [ "$answer" == "y" ]; then
commit
fi
}
main $*
exit 0