-
Notifications
You must be signed in to change notification settings - Fork 120
/
Copy pathbulk-git.sh
executable file
·104 lines (91 loc) · 1.95 KB
/
bulk-git.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
#!/bin/bash
# number of arguments... $#
echo "Git push across multiple projects - A script to save time"
echo
PS3="Please enter your choice: "
options=("Confirm All" "Confirm Single" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Confirm Single")
echo "Confirm files individually"
break
;;
"Confirm All")
echo "Confirm all files"
break
;;
"Quit")
exit 0
;;
*) echo "invalid option $opt";;
esac
done
echo
PS3="Please enter your choice: "
options2=("Diff" "Pull" "Push")
select opt2 in "${options2[@]}"
do
case $opt2 in
"Diff")
echo "Do git diff"
break
;;
"Pull")
echo "Do git pull"
break
;;
"Push")
echo "Do git push"
break
;;
*) echo "invalid option $opt2";;
esac
done
declare -a PACKAGES=(
"cookbook"
"jscommon"
"express-template"
"vue-antd-template"
)
BASEPATH=`cd .. && pwd`
# BASEPATH=`pwd`
# TO IMPROVE GET CHOICE TO CHOOSE INDIVIDUALLY OR DO FOR ALL
echo "Running pushes..."
echo
for package in "${PACKAGES[@]}"
do
DOIT="Y"
packagePath="${BASEPATH}/${package}"
if [ "$opt" == "Confirm Single" ]; then
echo -n "Run for... ${package} (y/n)? "
read DOIT
fi
if [ "$DOIT" != "${DOIT#[Yy]}" ]; then
# or do whatever with individual element of the array
echo "Running for... ${package}"
cd $packagePath
if [ "$opt2" == "Diff" ]; then
echo `git diff`
elif [ "$opt2" == "Push" ]; then
echo `git add .`
echo `git commit -m "update"`
if [ "$package" == "cookbook" ]; then
echo "Push for cookbook project manually"
else
echo `git push origin main`
fi
elif [ "$opt2" == "Pull" ]; then
if [ "$package" == "cookbook" ]; then
echo "Push for cookbook project manually"
else
echo `git pull origin main`
fi
fi
else
echo "Skipped... ${packagePath}"
fi
done
# echo checking app
echo done...
read