Ur Commands

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
gerrit apropos
Search Gerrit documentation index.

gerrit ban-commit
Bans a commit from a project’s repository.

gerrit create-branch
Create a new project branch.

gerrit ls-groups
List groups visible to the caller.

gerrit ls-members
List the membership of a group visible to the caller.

gerrit ls-projects
List projects visible to the caller.

gerrit query
Query the change database.

'gerrit receive-pack'
'Deprecated alias for git receive-pack.'

gerrit rename-group
Rename an account group.

gerrit review
Verify, approve and/or submit a patch set from the command line.

gerrit set-head
Change the HEAD reference of a project.

gerrit set-reviewers
Add or remove reviewers on a change.

gerrit stream-events
Monitor events occurring in real time.

gerrit version
Show the currently executing version of Gerrit.

git receive-pack
Standard Git server side command for client side git push.

Also implements the magic associated with uploading commits for review. See Creating Changes.

git upload-pack
Standard Git server side command for client side git fetch.

Administrator Commands

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
gerrit close-connection
Close the specified SSH connection.

gerrit create-account
Create a new user account.

gerrit create-group
Create a new account group.

gerrit create-project
Create a new project and associated Git repository.

gerrit flush-caches
Flush some/all server caches from memory.

gerrit gc
Run the Git garbage collection.

gerrit gsql
Administrative interface to active database.

gerrit index activate
Activate the latest index version available.

gerrit index start
Start the online indexer.

gerrit logging ls-level
List loggers and their logging level.

gerrit logging set-level
Set the logging level of loggers.

gerrit ls-user-refs
Lists refs visible for a specified user.

gerrit plugin add
Alias for 'gerrit plugin install'.

gerrit plugin enable
Enable plugins.

gerrit plugin install
Install/Add a plugin.

gerrit plugin ls
List the installed plugins.

gerrit plugin reload
Reload/Restart plugins.

gerrit plugin remove
Disable plugins.

gerrit plugin rm
Alias for 'gerrit plugin remove'.

gerrit set-account
Change an account’s settings.

gerrit set-members
Set group members.

gerrit set-project
Change a project’s settings.

gerrit set-project-parent
Change the project permissions are inherited from.

gerrit show-caches
Display current cache statistics.

gerrit show-connections
Display active client SSH connections.

gerrit show-queue
Display the background work queues, including replication.

gerrit test-submit rule
Test prolog submit rules.

gerrit test-submit type
Test prolog submit type.

kill
Kills a scheduled or running task.

ps
Alias for 'gerrit show-queue'.

suexec
Execute a command as any registered user account.
1
2
3
4
5
6
7
8
9
10
11

jenkins_key='ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3bWrhNlTkjlaomlwhIQZwQzptTueFzRJyH1h2Us2a5RixkEnpKfnBpY0XxKgCr/jq2lmC+Iz7dwvuK4t88m+/pWtTnRF9StgSeAiWHpJye+eOnz5OqAbP+Xo6ccQzhyKueG9WCHol8HqylVAAeIjeO2IcONAGwcgBlxNTKC+NU4YhrjpIfis0nzfIRggw6qhH9V1/uVm1oxSxlzqDsRUThnRKSmmomh4iaSlsChjqXXKzvP7ZkkElBMzCHgD6oEMM/v9Qlf2fox5thUEGtfAjIfPXF5Ntn+rsW0olcZsOVqB/IkSsw7rOCILhZw2qQ76zkXqiD5SgF/qYF9kvqwzn jenkins@马哥私房菜.'



ssh 10.0.12.27 gerrit version

echo $jenkins_key | ssh -p 29418 10.0.12.27 gerrit create-account --group "'Non-Interactive Users'" --full-name 'Jenkins-master' --email 'jenkins@马哥私房菜.com' --ssh-key - jenkins



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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256


ssh gerrit.example.com gerrit flush-caches –all

ssh gerrit.example.com gerrit show-queue -w

ssh -p 29418 gerrit.example.com gerrit create-project git/android/platform/vendor/example/proprietary/nv_ops_interface --empty-commit --parent Permission_parent/All-bsp --submit-type REBASE_IF_NECESSARY --branch pollux_bringup_20160816

ssh -p 29418 gerrit.example.com gerrit create-project k2/platform/vendor/example/packages/apps/MtsCommon --empty-commit --parent Permission_parent/All-bsp --submit-type REBASE_IF_NECESSARY --branch zs_msm8909_master

ssh -p 29418 gerrit.example.com gerrit create-project k2/platform/vendor/example/packages/apps/RadioFrequencyBackground --empty-commit --parent Permission_parent/All-bsp --submit-type REBASE_IF_NECESSARY --branch zs_msm8909_master


for s in $(ssh -p 29418 gerrit.example.com gerrit show-connections -w|grep arron|awk -F " " '{print $1}')
ssh -p 29418 gerrit.example.com gerrit close-connection $s




gerrit上面创建新的项目

ssh -p 29418 gerrit.example.com gerrit create-project $pro --empty-commit --parent Permission_parent/All-bsp --submit-type REBASE_IF_NECESSARY --branch zs_msm8909_master

ssh -p 29418 gerrit.example.com gerrit create-project $pro --empty-commit --parent Permission_parent/All-bsp --submit-type REBASE_IF_NECESSARY

ssh -p 29418 gerrit.example.com gerrit create-project k2/ platform/vendor/example/packages/apps/ZsRunInTest --empty-commit --parent Permission_parent/All-bsp --submit-type REBASE_IF_NECESSARY --branch zs_msm8909_master

ssh -p 29418 gerrit.example.com gerrit create-project m0/ruby/platform/vendor/letv_sh/proprietary/nv_ops_interface --empty-commit --parent Permission_parent/All-bsp --submit-type REBASE_IF_NECESSARY –branch

gerrit上面创建新的项目

for pro in $(more list )

ssh -p 29418 gerrit.example.com gerrit create-project $pro --empty-commit --parent Permission_parent/All-bsp --submit-type REBASE_IF_NECESSARY --branch zs_msm8909_master



设置gerrit项目的submit类型,推荐使用rebaseif necessary

ssh -p 29418 gerrit.example.com gerrit set-project k2/device/asus/deb --submit-type REBASE_IF_NECESSARY

设置gerrit项目的submit类型,推荐使用rebaseif necessary

for p in $(more list)

ssh -p 29418 gerrit.example.com gerrit set-project $p --submit-type REBASE_IF_NECESSARY

设置gerrit所有的项目的submit类型,推荐使用rebaseif necessary

for p in $(ssh gerrit.example.com gerrit ls-projects)

do

ssh -p 29418 gerrit.example.com gerrit set-project $p --submit-type REBASE_IF_NECESSARY

done



for p in $( ssh gerrit.example.com gerrit ls-projects|grep "coolpad" )

do

ssh -p 29418 gerrit.example.com gerrit set-project $p --submit-type REBASE_IF_NECESSARY


done

for p in $(ssh gerrit.example.com gerrit ls-projects |grep "/coolpad/" )

do

ssh gerrit.example.com gerrit set-project-parent $p --parent Permission_parent/All-ui

done



批量克隆gerrit上面的仓库,方法1

$ ssh -p 29418 dianar gerrit ls-projects > letv-all.list

$ for p in $(more letv-all.list)

echo git clone ssh://ellen.liu_w@dianar:29418/$p $p --mirror



批量克隆gerrit上面的仓库,方法2

for p in $(ssh -p 29418 dianar gerrit ls-projects)

echo git clone ssh://ellen.liu_w@dianar:29418/$p $p --mirror





ssh -p 29418 gerrit.example.com gerrit create-project k2/platform/vendor/example/packages/apps/atchannel --empty-commit --parent Permission_parent/All-bsp --submit-type REBASE_IF_NECESSARY --branch zs_msm8909_master



添加ssh-key

cat ~/.ssh/id_rsa.pub |ssh -p 29418 gerrit.example.com gerrit set-account --add-ssh-key - jenkins





删除某个人ssh连接

ssh -p 29418 gerrit.example.com gerrit show-connections -w|awk -F " " '{print $1 ":" $3}'|awk -F ":" '$2>=5{print $1}'



$ for s in $(ssh -p 29418 gerrit.example.com gerrit show-connections -w|grep owen.li|awk -F " " '{print $1}')

ssh -p 29418 gerrit.example.com gerrit close-connection $s



for ss in $(ssh -p 29418 gerrit.example.com gerrit show-connections -w|awk -F " " '{print $1 ":" $3}'|awk -F ":" '$2>=5{print $1}')

ssh -p 29418 gerrit.example.com gerrit close-connection $ss





列出某个project的分支的访问权限。列出的是可以访问的分支名称

ssh gerrit.example.com gerrit ls-user-refs --project git/android/device/generic/mips --user buildfarm --only-refs-heads|sort





22端口重定向

sudo iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 22 -j REDIRECT --to-port 29418





tar zcf - review_site | ssh gerrit2@10.0.12.21 'tar zxf -'

tar zcf - review_site | ssh gerrit2@10.0.12.21 'tar zxf -'



createuser --username=postgres -RDIElPS gerrit2

createdb --username=postgres -E UTF-8 -O gerrit2 reviewdb



切换到postgre用户执行:

psql -d reviewdb -f ./reviewdb.sql



lrwxrwxrwx 1 root root 16 10月 22 08:14 /etc/rc0.d/K90gerrit -> ../init.d/gerrit*

lrwxrwxrwx 1 root root 16 10月 22 08:14 /etc/rc1.d/K90gerrit -> ../init.d/gerrit*

lrwxrwxrwx 1 root root 16 10月 22 08:14 /etc/rc2.d/S90gerrit -> ../init.d/gerrit*

lrwxrwxrwx 1 root root 16 10月 22 08:14 /etc/rc3.d/S90gerrit -> ../init.d/gerrit*

lrwxrwxrwx 1 root root 16 10月 22 08:14 /etc/rc4.d/S90gerrit -> ../init.d/gerrit*

lrwxrwxrwx 1 root root 16 10月 22 08:14 /etc/rc5.d/S90gerrit -> ../init.d/gerrit*

lrwxrwxrwx 1 root root 16 10月 22 08:14 /etc/rc6.d/K90gerrit -> ../init.d/gerrit*







所有仓库执行git gc命令
#cd /home/gerrit2/review_site/git/git && find . -name "*.git" -type d -exec bash -c 'src="{}"; echo =$src=; git -C $src gc' \;

ssh gerrit.example.com gerrit gc --all --show-progress






gerrit迁移笔记
tar zcf - review_site | ssh gerrit2@10.0.12.21 'tar zxf -'
tar zcf - review_site | ssh gerrit2@10.0.12.21 'tar zxf -'

createuser --username=postgres -RDIElPS gerrit2
createdb --username=postgres -E UTF-8 -O gerrit2 reviewdb

切换到postgre用户执行:
psql -d reviewdb -f ./reviewdb.sql



cat > ~/.ssh/config <<EOF
Host gerrit.example.com
User vic.yang_cp

Host gerrit-sz.example.com
User vic.yang_cp

Host gerrit-xi.example.com
User vic.yang_cp

Host gerrit-sh.example.com
User vic.yang_cp
EOF

ssh -o StrictHostKeyChecking=no -p 29418 gerrit-sh.example.com gerrit version
ssh -o StrictHostKeyChecking=no -p 29418 gerrit-sz.example.com gerrit version
ssh -o StrictHostKeyChecking=no -p 29418 gerrit-xi.example.com gerrit version

exit 0



1517 rsync -rlvpa gerrit-hk.example.com:~/gerrit.war/ gerrit.war/
1518 man rsync
1519 rsync -rlvpa -e 'ssh -p 22' gerrit-hk.example.com:~/gerrit.war/ gerrit.war/
1520 rsync -rlvpa -e 'ssh -p 22' gerrit2@gerrit-hk.example.com:~/gerrit.war/ gerrit.war/
1522 rsync -rlvpa -e 'ssh -p 22' gerrit2@gerrit-hk.example.com:~/gerrit.war/ gerrit.war/
1526 rsync -rlvpa -e 'ssh -p 22' gerrit2@gerrit-hk.example.com:~/gerrit.war/ gerrit.war/
1528 rsync -rvlpa gerrit.war/ mamh@10.0.63.21:~/gerrit.war/
1607 rsync -rlvpa /home/gerrit2/review_site/git/git/android/ 10.0.12.62:/home/gerrit2/review_site/git/git/android/
1650 history |grep rsync
1651 rsync -rlvpa -e 'ssh -p 22' gerrit-hk.example.com:~/gerrit.war/ gerrit.war/
1652 rsync -rlvpa -e 'ssh -p 22' gerrit2@gerrit-hk.example.com:~/gerrit.war/ gerrit.war/
1653 rsync -rvlpa gerrit.war/ mamh@10.0.63.21:~/gerrit.war/
1936 history |grep rsync
1938 rsync -rlvpa /home/gerrit2/review_site/git/git/android/ 10.0.12.62:/home/gerrit2/review_site/git/git/android/
1943 rsync -rlvpa /home/gerrit2/backup/20181020065101.db.gz 10.0.12.62:/home/gerrit2/
1956 history |grep rsync
1957 rsync -rlvpa /home/gerrit2/review_site/ 10.0.12.32:/home/gerrit2/review_site1/ --exclude=git/git/aosp --exclude=git/git/shared --exclude=git/git/private
1959 rsync -rlvpa /home/gerrit2/backup/ 10.0.12.32:/home/gerrit2/2018-10-20_132417_v2.12.db.bak/
1963 rsync -rlvpa /home/gerrit2/backup/ 10.0.12.32:/home/gerrit2/2018-10-20_132417_v2.12.db.bak/
1964 history |grep rsync
1965 rsync -rlvpa /home/gerrit2/review_site/ 10.0.12.32:/home/gerrit2/review_site1/ --exclude=git/git/aosp --exclude=git/git/shared --exclude=git/git/private
1967 rsync -rlvpa /home/gerrit2/gerrit.war/ 10.0.12.32:/home/gerrit2/gerrit.war/
1971 history |grep rsync
1972 rsync -rlvpa /home/gerrit2/backup/ 10.0.12.32:/home/gerrit2/2018-10-20_132417_v2.12.db.bak/




1
2
3
4
5
6
7
8
9
10
11
12

for p in $(ssh -p29418 gerrit-bak.example.com gerrit ls-projects )
do
echo "=will set project-parent for $p="
ssh gerrit-bak.example.com gerrit set-project-parent "$p" --parent All-Projects
done

for p in $(ssh -p29419 gerrit-bak.example.com gerrit ls-projects )
do
echo "=will set project-parent for $p="
ssh -p29419 gerrit-bak.example.com gerrit set-project-parent "$p" --parent All-Projects
done