forked from AndroidOpenSourceXperia/android_scripts
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Fetch.sh
executable file
·140 lines (126 loc) · 2.73 KB
/
Fetch.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#! /bin/bash
#cd xste
branch="cm-12.1"
remote="CyanogenMod"
urlstart="https://github.com/CyanogenMod/android_"
urlend=".git"
gitstart="[email protected]:XperiaSTE/android_"
#gitstart="https://github.com/XperiaSTE/android_"
gitend=".git"
path=(
bionic
build
bootable/recovery
external/icu
frameworks/av
frameworks/base
frameworks/native
hardware/libhardware
hardware/libhardware_legacy
packages/apps/Eleven
packages/apps/Settings
packages/services/Telecomm
system/core
vendor/cm
)
#############
# Read array $path lenght
repos=$(echo ${#path[@]} )
read -r -p "Do you wish to add remotes? [y/N] " response
response=${response,,}
if [[ $response =~ ^(yes|y)$ ]]
then
for ((i = 0; i < $repos; i++))
do
echo "Adding remote ${remote} to ${path[i]}"
# Exception
if [[ ${path[i]} == bootable/recovery ]]; then
url="https://github.com/omnirom/android_bootable_recovery.git"
remote="omnirom"
else
# Generate url from $path
url="${urlstart}$(echo ${path[i]} | sed 's.\/._.g')${urlend}"
remote="CyanogenMod"
fi
git -C ${path[i]} remote remove ${remote}
git -C ${path[i]} remote add ${remote} ${url}
done
echo
fi
read -r -p "Do you wish to fetch remotes? [y/N] " response
response=${response,,}
if [[ $response =~ ^(yes|y)$ ]]
then
for ((i = 0; i < $repos; i++))
do
echo "Fetching ${path[i]}"
# Exception
if [[ ${path[i]} == bootable/recovery ]]; then
remote="omnirom"
fi
git -C ${path[i]} fetch ${remote}
remote="CyanogenMod"
done
echo
fi
read -r -p "Do you wish to change branches? [y/N] " response
response=${response,,}
if [[ $response =~ ^(yes|y)$ ]]
then
for ((i = 0; i < $repos; i++))
do
# Exception
if [[ ${path[i]} == bootable/recovery ]]; then
branch="android-6.0"
else
branch="cm-12.1"
fi
echo "Changing ${path[i]} branch to $branch"
git -C ${path[i]} branch temp
git -C ${path[i]} checkout temp
git -C ${path[i]} branch -D $branch
git -C ${path[i]} branch $branch
git -C ${path[i]} checkout $branch
git -C ${path[i]} branch -D temp
done
echo
fi
read -r -p "Do you wish to merge changes? [y/N] " response
response=${response,,}
if [[ $response =~ ^(yes|y)$ ]]
then
for ((i = 0; i < $repos; i++))
do
echo "Merging changes to ${path[i]}"
# Exception
if [[ ${path[i]} == bootable/recovery ]]; then
remote="omnirom"
branch="android-6.0"
else
remote="CyanogenMod"
branch="cm-12.1"
fi
git -C ${path[i]} merge ${remote}/${branch}
echo
done
fi
read -r -p "Do you wish to push changes? [y/N] " response
response=${response,,}
if [[ $response =~ ^(yes|y)$ ]]
then
#eval `ssh-agent -s`
#ssh-add
for ((i = 0; i < $repos; i++))
do
# Exception
if [[ ${path[i]} == bootable/recovery ]]; then
branch="android-6.0"
else
branch="cm-12.1"
fi
echo "Pushing ${path[i]} changes"
git="${gitstart}$(echo ${path[i]} | sed 's.\/._.g')${gitend}"
git -C ${path[i]} push ${git} ${branch}
done
fi
exit