-
Notifications
You must be signed in to change notification settings - Fork 3
/
gerrit
50 lines (33 loc) · 2.35 KB
/
gerrit
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
# review and submit
ssh -p 29418 username@review.site.com gerrit review --verified +1 --code-review +2 --submit gerritid,2
# query information from gerrit
ssh -p 29418 username@review.site.com gerrit query --format=JSON --commit-message gerritid --current-patch-set
ssh -p 29418 username@review.site.com gerrit query gerritid --current-patch-set
# create project
ssh -p 29418 review.example.com gerrit create-project --parent All-Projects tools/gerrit.git
# query current open change by parent projct
${SSH_GERRIT_COMMAND} query --current-patch-set parentproject:${parent_project} status:open | grep ' ref: refs/changes' | sed -r 's# ref: refs/changes/[0-9]+/(.*)#\1#g' | sed 's#/#,#g'
# merge change
${SSH_GERRIT_COMMAND} review --verified +1 --code-review +2 --submit ${change}
# http
curl --digest -k -u 'username':'gerrit http password' 'https://gerrit.url/a/changes/?q=15&o=CURRENT_REVISION'
# flush cache
ssh -p 29418 review.example.com gerrit flush-caches --all
# query paramters
owner:xxx@xxx.com status:merged file:^.*java message:xxx
# set prefered mail
ssh -p 29418 user@review.example.com gerrit set-account --add-email xxx@xxx.com account
ssh -p 29418 user@review.example.com gerrit set-account --preferred-email xxx@xxx.com account
# query by time example
status:merged branch:branch-name after:2018-12-28
status:merged (branch:branch1 OR branch:branch2) after:2019-01-22 (NOT owner:ci-bot)
# query gerritid by topic
ssh -p 29418 user@review.example.com gerrit query topic:xxxxx | grep number: | awk -F ': ' '{print $2}' | sort | uniq | xargs
# query cherry-pick list for git fetch
ssh -p 29418 user@review.example.com gerrit query topic:xxxxx --current-patch-set | egrep -e 'ref:' -e "project:" | awk -F ': ' '{print $2}' | sed 'N;s/\n/ /'
# review by topic
for revision in $(ssh -p 29418 user@review.example.com gerrit query --current-patch-set --format=JSON topic:xxxxxxx | sed '$d' | jq '.currentPatchSet.revision'); do revision=$(echo $revision | sed 's/\"//g'); ssh -p 29418 user@review.example.com gerrit review --code-review +1 $revision; done
# push patch
for sha1 in $(echo "$(git log xxxxxxx..HEAD --pretty=format:"%H" --no-merges)" | tac); do git push origin $sha1:refs/for/xxx_branch%submit; done
# push merged patch
for sha1 in $(echo "$(git log xxxx..HEAD --pretty=format:"%H" --no-merges)" | tac); do git push origin $sha1:refs/for/xxx_BRANCH%merged; done