forked from gothicVI/AndroidDevelopment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlineageos-gerrit-repopick-topic.sh
105 lines (86 loc) · 2.37 KB
/
lineageos-gerrit-repopick-topic.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
#
# Source it from your LineageOS build environment:
#
# . lineageos-gerrit-repopick-topic.sh
#
# then use it, for example:
#
# repopick_topic n-asb-2020-05
#
# to pick the May 2020 ASB for LineageOS 14.1
#
# Author: Vasyl Gello <[email protected]>
repopick_topic()
{
_TOPIC="$1"
_GERRIT_HOSTNAME="review.lineageos.org"
_OLDPWD="$PWD"
command -v croot 1>/dev/null 2>/dev/null
if [ $? -ne 0 ]; then
echo "ERROR: LineageOS build environment not sourced!"
echo "Make sure '. build/envsetup.sh' was invoked!"
unset _TOPIC
unset _GERRIT_HOSTNAME
cd "$_OLDPWD"
unset _OLDPWD
exit 1
fi
croot
if [ $? -ne 0 ]; then
unset _TOPIC
unset _GERRIT_HOSTNAME
cd "$_OLDPWD"
unset _OLDPWD
exit 1
fi
if [ -z "$_TOPIC" ]; then
echo "Usage: repopick_topic <topic-name>"
unset _TOPIC
unset _GERRIT_HOSTNAME
cd "$_OLDPWD"
unset _OLDPWD
exit 1
fi
_MANIFEST_CHANGES="$(curl --get "https://$_GERRIT_HOSTNAME/changes/" \
--data-urlencode "q=topic:$_TOPIC project:LineageOS/android" | \
grep "\"_number\"" | grep -ioe "[0-9]*")"
croot
if [ ! -z "$_MANIFEST_CHANGES" ]; then
_MANIFEST_CHANGES_COUNT=0
cd .repo/manifests
for _MANIFEST_CHANGE in $_MANIFEST_CHANGES
do
curl "https://$_GERRIT_HOSTNAME/changes/$_MANIFEST_CHANGE/revisions/current/patch" | \
base64 -d | LANG=C git am -3 --ignore-whitespace --ignore-space-change -
if [ $? -ne 0 ]; then
echo "Error: can not apply change $_MANIFEST_CHANGE to .repo/manifests"
LANG=C git am --abort 1>/dev/null 2>/dev/null
if [ $_MANIFEST_CHANGES_COUNT -gt 0 ]; then
LANG=C git reset --hard "HEAD~$_MANIFEST_CHANGES_COUNT" \
1>/dev/null 2>/dev/null
fi
unset _MANIFEST_CHANGE
unset _MANIFEST_CHANGES
unset _MANIFEST_CHANGES_COUNT
unset _TOPIC
unset _GERRIT_HOSTNAME
cd "$_OLDPWD"
unset _OLDPWD
exit 1
else
_MANIFEST_CHANGES_COUNT=$(( _MANIFEST_CHANGES_COUNT + 1 ))
fi
done
croot
#repo sync -q --force-sync
repo sync -v -j 1 -c --no-tags --no-clone-bundle --force-sync --fail-fast 2>&1 || exit 1
fi
repopick -t "$_TOPIC"
unset _MANIFEST_CHANGE
unset _MANIFEST_CHANGES
unset _MANIFEST_CHANGES_COUNT
unset _TOPIC
unset _GERRIT_HOSTNAME
cd "$_OLDPWD"
unset _OLDPWD
}