-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathc
executable file
·131 lines (123 loc) · 3.31 KB
/
c
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
#!/bin/bash
# ~/x/c - control script
if [ "$#" -eq 0 ]
then
echo "Usage: `basename $0` [pull] [update] [updated [[submodule] [file]]] [pip-upgrade] [remove-submodule [path]]" >&2
exit 1
fi
cd ~/x
remove-submodule() {
# https://gist.github.com/sharplet/6289697
# Adam Sharp
# Aug 21, 2013
submodule_name=$(echo "$1" | sed 's/\/$//'); shift
echo "$submodule_name"
if git submodule status "$submodule_name" >/dev/null 2>&1; then
git submodule deinit -f "$submodule_name"
git rm -f "$submodule_name"
#git config -f .gitmodules --remove-section "submodule.$submodule_name"
if [ -z "$(cat .gitmodules)" ]; then
git rm -f .gitmodules
else
git add .gitmodules
fi
rm -rf ".git/modules/$submodule_name"
else
echo "Submodule '$submodule_name' not found" >&2
return 1
fi
}
pull() {
git stash
#git pull origin master
git pull --rebase --stat
git mergetool
#git checkout
git stash pop
git submodule update --init --recursive
git submodule foreach git checkout
#git checkout -f origin/master
git mergetool
#git stash clear
}
update() {
echo -e "\e[94mDownloading releases...\e[39m"
cd ~/x/e/releases
./get-newest-releases
cd - >/dev/null
cd ~/x
git submodule update --init --recursive
git submodule foreach git checkout
cd - >/dev/null
find {b,p} -maxdepth 4 -name ".git" | sed 's/.git$//' | while read i
do
echo -e "\e[94m$i\e[39m"
cd $i
#git checkout
#git pull origin master
git pull --rebase --stat || { git checkout master && git pull --rebase --stat origin master ; }
#git status
cd - >/dev/null
done
}
#for p in "$@"
while [ $# -ne 0 ]
do
p=$1
shift
case "$p" in
"pull")
pull
;;
"update")
update
;;
"updated")
# repo
r=""
if [ $# -ne 0 ]
then
r=$1
shift
fi
# file
f=""
if [ $# -ne 0 ]
then
f=$1
shift
fi
find {b,p} -maxdepth 4 -name ".git" | sed 's/.git$//' | while read i
do
old=`git diff $i | egrep "^-Subproject" | awk '{print $3}'`
if [ "$old" != "" ]
then
if [ "$r" != "" ]
then
if [ "$r" == "$i" -o "$r/" == "$i" ]
then
cd $i
if [ "$f" != "" ]
then
git diff $old -- $f
else
git diff $old --stat
fi
cd - >/dev/null
fi
else
echo -e "\e[94m$i\e[39m"
fi
fi
done
;;
"remove-submodule")
remove-submodule "$1"
shift
;;
"pip-upgrade")
echo "# Usage: ~/x/c pip-upgrade | bash"
echo 'pip freeze --local | awk -F= "{print $1}" | xargs -n1 -- pip install --upgrade'
;;
esac
done