3 #GERRITHOST=gerrit.libreoffice.org
5 GERRITURL
=ssh://$GERRITHOST/core
8 SHA
=`ssh ${GERRITHOST?} gerrit query --all-approvals change:$1|grep ref|tail -1|cut -d: -f2`
11 get_REVISION_for_change
() {
12 REVISION
=`ssh ${GERRITHOST?} gerrit query --all-approvals change:$1|grep revision|tail -1|cut -d: -f2`
17 [yY
] |
[yY
][Ee
][Ss
] |
[+] )
20 [nN
] |
[n|N
][O|o
] |
[-] )
27 echo "Please answer with either +,-,y,n,yes,no or the empty string."
38 BRANCH
=`git symbolic-ref HEAD 2> /dev/null`
39 BRANCH
="${BRANCH##refs/heads/}"
42 echo "no branch specified, and could not guess the current branch"
45 echo "no branch specified, guessing current branch $BRANCH"
47 git push
$GERRITURL HEAD
:refs
/for
/$BRANCH
52 echo "Usage: ./logerrit subcommand [options]"
53 echo "simple and basic tool to interact with LibreOffice gerrit"
55 echo " test test your gerrit setup"
56 echo " --- for submitters:"
57 echo " submit [BRANCH] submit your change for review"
58 echo " resubmit [BRANCH] create a new Change-Id and submit your change for review"
59 echo " (yes, this modifies your last commit)"
60 echo " nextchange [BRANCH] reset branch to the remote to start with the next change"
61 echo " --- for reviewers:"
62 echo " checkout CHANGEID checkout the changes for review"
63 echo " pull CHANGEID pull (and merge) the changes on current branch"
64 echo " cherry-pick CHANGEID cherry-pick the change on current branch"
65 echo " patch CHANGEID show the change as a patch"
66 echo " review [CHANGEID] interactively review a change (current one if no changeid given)"
67 echo " query .... query for changes for review on project core"
68 echo " <any other gerrit command>"
69 echo "advanced users should consider using git review instead:"
70 echo "http://wiki.documentfoundation.org/Development/GitReview"
74 if test -n "`ssh $GERRITHOST 2>&1|grep \"Welcome to Gerrit Code Review\"`"
76 echo "Your gerrit setup was successful!"
78 echo "There seems to be trouble."
79 echo "please have the output of: ssh -vvvv logerrit"
80 echo "at hand when looking for help."
87 git log
-1 --pretty=%B |
grep -v ^Change-Id
: | git commit
--amend -F -
91 if test -n "`git status -s -uno`"
93 echo "You have uncommitted changes. Please commit or stash these:"
97 CHANGEID
=`git log --format=format:%b -1 HEAD|grep Change-Id|cut -d: -f2|tr -d \ `
98 if test -z "$CHANGEID"
100 CHANGEID
="NOCHANGEID"
102 BACKUPBRANCH
=backup
/$CHANGEID-`date +%F-%H%M%S`
103 git branch
$BACKUPBRANCH
104 echo "current state backed up as $BACKUPBRANCH"
108 BRANCH
=`git symbolic-ref HEAD 2> /dev/null`
109 BRANCH
="${BRANCH##refs/heads/}"
112 echo "no branch specified, and could not guess the current branch"
115 echo "no branch specified, guessing current branch $BRANCH"
117 git
reset --hard remotes
/origin
/$BRANCH
121 if test -z "$CHANGEID"
123 CHANGEID
=`git log --format=format:%b -1 HEAD|grep Change-Id|cut -d: -f2`
124 if test -z "$CHANGEID"
126 echo "could not find a Change-Id in your last commit, sorry"
129 echo "no Change-Id given on the command line, reviewing change$CHANGEID"
132 read -p 'was the change verified to build successfully (+) or found not to build (-) or none of that ()? ' VERIFIED
133 ask_tristate
$VERIFIED
136 VERIFIEDFLAG
=--verified=+1
139 VERIFIEDFLAG
="--verified=-1"
140 MESSAGEREQ
="$MESSAGEREQ and explain why you could not verify this"
143 VERIFIEDFLAG
="--verified=0"
147 read -p 'is the code looking good (+), bad (-) or none of that ()? ' CODEREVIEW
148 ask_tristate
$CODEREVIEW
152 read -p 'do you approve the change (+) too, or prefer someone else to do that ()? ' CODEREVIEW
153 ask_tristate
$CODEREVIEW
156 CODEREVIEWFLAG
="--code-review=2"
157 SUBMITFLAG
="--submit"
160 CODEREVIEWFLAG
="--code-review=1"
163 CODEREVIEWFLAG
="--code-review=1"
168 read -p 'do you still allow the change to go in () or not (-)? ' CODEREVIEW
169 ask_tristate
$CODEREVIEW
172 CODEREVIEWFLAG
="--code-review=-1"
173 MESSAGEREQ
="$MESSAGEREQ and explain why you have reservations about the code"
176 CODEREVIEWFLAG
="--code-review=-2"
177 MESSAGEREQ
="$MESSAGEREQ and explain why you want to block this"
180 CODEREVIEWFLAG
="--code-review=-1"
181 MESSAGEREQ
="$MESSAGEREQ and explain why you have reservations about the code"
188 read -p "please type a friendly comment$MESSAGEREQ: " MESSAGE
189 get_REVISION_for_change
$CHANGEID
190 ssh ${GERRITHOST?} gerrit review
-m \"$MESSAGE\" $VERIFIEDFLAG $CODEREVIEWFLAG $SUBMITFLAG $REVISION
193 get_SHA_for_change
$2
194 git fetch
$GERRITURL $SHA && git checkout FETCH_HEAD
197 get_SHA_for_change
$2
198 git pull
$GERRITURL $SHA
201 get_SHA_for_change
$2
202 git fetch
$GERRITURL $SHA && git cherry-pick FETCH_HEAD
205 get_SHA_for_change
$2
206 git fetch
$GERRITURL $SHA && git format-patch
-1 --stdout FETCH_HEAD
210 ssh ${GERRITHOST?} gerrit query project
:core $@
213 ssh ${GERRITHOST?} gerrit $@