lok: add character parameter to renderFont
[LibreOffice.git] / logerrit
blob6e7338aad0aac518c7fa2dc4409fc6efcf8efd53
1 #!/bin/sh
3 #GERRITHOST=gerrit.libreoffice.org
4 GERRITHOST=logerrit
5 GERRITURL=ssh://$GERRITHOST/core
7 get_SHA_for_change() {
8 SHA=`ssh ${GERRITHOST?} gerrit query --all-approvals change:$1|grep ref|tail -1|cut -d: -f2`
11 submit() {
12 TYPE=$1
13 BRANCH=$2
14 if test -z "$BRANCH"
15 then
16 BRANCH=`git symbolic-ref HEAD 2> /dev/null`
17 BRANCH="${BRANCH##refs/heads/}"
18 if test -z "$BRANCH"
19 then
20 echo "no branch specified, and could not guess the current branch"
21 exit 1
23 echo "no branch specified, guessing current branch $BRANCH"
25 git push $GERRITURL HEAD:refs/$TYPE/$BRANCH
28 logerrit() {
29 echo "Host logerrit gerrit.libreoffice.org"
30 echo " IdentityFile ~/.ssh/id_rsa"
31 echo " User $1"
32 echo " Port 29418"
33 echo " HostName gerrit.libreoffice.org"
36 case "$1" in
37 help|--help|"")
38 echo "Usage: ./logerrit subcommand [options]"
39 echo "simple and basic tool to interact with LibreOffice gerrit"
40 echo "see https://wiki.documentfoundation.org/Development/gerrit for details."
41 echo
42 echo "subcommands:"
43 echo " setup walking you though your gerrit setup"
44 echo " test test your gerrit setup"
45 echo
46 echo " --- for submitters:"
47 echo " submit [BRANCH] submit your change for review"
48 echo " submit-draft [BRANCH] submit your change as draft"
49 echo " nextchange [BRANCH] reset branch to the remote to start with the next change"
50 echo " testfeature [BRANCH] trigger a test of a feature branch on gerrit"
51 echo "Note: drafts are only visibly to yourself and those that you explicitly add as reviewers."
52 echo
53 echo " --- for reviewers:"
54 echo " checkout CHANGEID checkout the changes for review"
55 echo " pull CHANGEID pull (and merge) the changes on current branch"
56 echo " cherry-pick CHANGEID cherry-pick the change on current branch"
57 echo " patch CHANGEID show the change as a patch"
58 echo " query .... query for changes for review on project core"
59 echo " <any other gerrit command>"
60 echo
61 echo "advanced users should consider using git review instead:"
62 echo "http://wiki.documentfoundation.org/Development/GitReview"
63 exit
65 setup)
66 cd $(dirname $(readlink -f $0))
67 ssh_home="$HOME/.ssh";
68 ssh_key=
69 created_ssh=
70 if ! test -d $ssh_home; then
71 echo "It appears that you have no ssh setup, running ssh-keygen to create that:"
72 mkdir $ssh_home
73 chmod 0700 $ssh_home
74 created_ssh=TRUE
75 echo
76 echo "Hit enter to generate an ssh key - you will need to enter a pass-phrase"
77 echo
78 read
79 ssh-keygen -t rsa -f "$ssh_home/id_rsa"
81 if test -d $ssh_home; then
82 if test -f "$ssh_home/id_rsa.pub"; then
83 ssh_key=`cat $ssh_home/id_rsa.pub`;
84 elif test -f "$ssh_home/id_dsa.pub"; then
85 ssh_key=`cat $ssh_home/id_dsa.pub`;
88 echo "Please go to https://gerrit.libreoffice.org/ and:"
89 echo "- press the 'register' button in the top right corner"
90 echo "- after login set yourself a username (its recommended to use your IRC-nick)"
91 if test "z$ssh_key" = "z"; then
92 echo "- add your public ssh-key into the ssh keys settings."
93 else
94 echo "- paste the key below into the 'Add SSH Public Key' box."
95 echo
96 echo "$ssh_key"
97 echo
99 echo
100 echo "Note that you need to register additional email addresses, if you want to"
101 echo "commit from them. Additional emails must be confirmed with repling to the"
102 echo "invitation mail it sends you."
103 echo
104 read -p 'Which user name did you choose? ' GERRITUSER
105 if test "z$created_ssh" = "z"; then
106 echo
107 echo "Please now add the following to your ~/.ssh/config, creating the file if needed:"
108 echo
109 logerrit $GERRITUSER
110 echo
111 else
112 echo "Automatically creating your ssh config"
113 (logerrit $GERRITUSER) > "$ssh_home/config"
115 # setup the remote properly ...
116 git config remote.origin.pushurl ssh://logerrit/core
117 echo "To see if your setup was successful, run './logerrit test' then."
118 # a good place to make sure the hooks are set up
119 ./g -z
121 test)
122 if test -n "`ssh $GERRITHOST 2>&1|grep \"Welcome to Gerrit Code Review\"`"
123 then
124 echo "Your gerrit setup was successful!"
125 else
126 echo "There seems to be trouble."
127 echo "please have the output of: ssh -vvvv logerrit"
128 echo "at hand when looking for help."
131 submit)
132 submit 'for' $2
134 submit-draft)
135 submit drafts $2
137 nextchange)
138 if test -n "`git status -s -uno`"
139 then
140 echo "You have uncommitted changes. Please commit or stash these:"
141 git status
142 exit 1
144 CHANGEID=`git log --format=format:%b -1 HEAD|grep Change-Id|cut -d: -f2|tr -d \ `
145 if test -z "$CHANGEID"
146 then
147 CHANGEID="NOCHANGEID"
149 BACKUPBRANCH=backup/$CHANGEID-`date +%F-%H%M%S`
150 git branch $BACKUPBRANCH
151 echo "current state backed up as $BACKUPBRANCH"
152 BRANCH=$2
153 if test -z "$BRANCH"
154 then
155 BRANCH=`git symbolic-ref HEAD 2> /dev/null`
156 BRANCH="${BRANCH##refs/heads/}"
157 if test -z "$BRANCH"
158 then
159 echo "no branch specified, and could not guess the current branch"
160 exit 1
162 echo "no branch specified, guessing current branch $BRANCH"
164 git reset --hard remotes/origin/$BRANCH
166 checkout)
167 get_SHA_for_change $2
168 git fetch $GERRITURL $SHA && git checkout FETCH_HEAD
170 review)
171 echo "'./logerrit review' has be removed as obsolete."
172 echo "Please use either:"
173 echo " - git-review: https://wiki.documentfoundation.org/Development/GitReview"
174 echo " - or the web-UI directly: https://gerrit.libreoffice.org/"
175 echo "Both provide a better experience."
176 exit 1;
178 pull)
179 get_SHA_for_change $2
180 git pull $GERRITURL $SHA
182 cherry-pick)
183 get_SHA_for_change $2
184 git fetch $GERRITURL $SHA && git cherry-pick FETCH_HEAD
186 patch)
187 get_SHA_for_change $2
188 git fetch $GERRITURL $SHA && git format-patch -1 --stdout FETCH_HEAD
190 query)
191 shift
192 ssh ${GERRITHOST?} gerrit query project:core $@
194 testfeature)
195 BRANCH=$2
196 if test -z "$BRANCH"
197 then
198 BRANCH=`git symbolic-ref HEAD 2> /dev/null`
199 BRANCH="${BRANCH##refs/heads/}"
200 if test -z "$BRANCH"
201 then
202 echo "no branch specified, and could not guess the current branch"
203 exit 1
205 echo "no branch specified, guessing current branch $BRANCH"
207 BRANCH="${BRANCH##feature/}"
208 WORKDIR=`mktemp -d`
209 if test -z "$WORKDIR"
210 then
211 echo "could no create work directory."
212 exit 1
214 echo workdir at $WORKDIR
215 git clone -s `dirname $0` $WORKDIR/core
216 pushd $WORKDIR/core
217 echo "noop commit: trigger test build for branch feature/$BRANCH" > ../commitmsg
218 echo >> ../commitmsg
219 echo "branch is at:" >> ../commitmsg
220 git log -1|sed -e "s/Change-Id:/XXXXXX:/" >> ../commitmsg
221 git fetch git://gerrit.libreoffice.org/core.git feature/$BRANCH && \
222 git checkout -b featuretst FETCH_HEAD && \
223 cp -a .git-hooks/* .git/hooks
224 git commit --allow-empty -F ../commitmsg && \
225 git push $GERRITURL HEAD:refs/for/feature/$BRANCH
226 popd
227 rm -rf $WORKDIR/core
230 ssh ${GERRITHOST?} gerrit $@
232 esac