Gerrit Memo
目录

Install

apache

sudo a2enmod proxy
sudo a2enmod proxy_http
sudo service apache2 restart
/etc/init.d/apache restart

https://stackoverflow.com/questions/8451717/gerrit-http-authentication

su - gerrit2
htpasswd ~/gerrit_usrs NEW_USER_NAME
~/gerrit_app/bin/gerrit.sh start
  • mysql: https://webcache.googleusercontent.com/search?q=cache:9zx8EemSBwsJ:https://gist.github.com/crazycode/6ff6770ac502ab1843e8+&cd=3&hl=zh-CN&ct=clnk&gl=cn
  • 用户邮件问题:http://blog.csdn.net/enlangs/article/details/21237327

Client

login gerrit-server-host -> settings -> http password -> generate password.  ## Use the password push changes via http.

http://www.cnblogs.com/xiaoerlang/p/3512432.html

git config user.name "YOUR_NAME"
git config user.email "YOUR_EMAIL"
git config push.default simple
curl -Lo <local path to your git>/.git/hooks/commit-msg <your Gerrit http URL>/tools/hooks/commit-msg
chmod u+x <local path to your git>/.git/hooks/commit-msg
git push origin HEAD:refs/for/master

免密码:

1.设置ssh 2.设置http认证

修改.git/config的[remote "orgion"]中url为
http://USERNAME:PASSWORD@IP/PATH 的形式

Submit 条件修改

只修改单个项目的submit条件

git clone <your project> (必须是ssh协议,http协议获取不到,必须是admin或project owner)
git fetch origin refs/meta/config
git checkout config
... edit or create the rules.pl file
git add rules.pl
git commit -m "My submit rules"
git push origin HEAD:refs/meta/config

rules.pl示例,需要2个CodeReview+2才能提交:

% Need two `CodeReview +2` commits to let change submittable
% Ranler Cao  caoran@fiberhome.com 2017/4/25

sum_list([], 0).
sum_list([H | Rest], Sum) :- sum_list(Rest,Tmp), Sum is H + Tmp.

score(Category, Score, User) :-
gerrit:commit_label(label(Category, Score), User),
Score >= 2.

add_category_min_score(In, Category, Min,  P) :-
findall(X, score(Category, X, R), Z),
sum_list(Z, Sum),
Sum >= Min, !,
gerrit:current_user(R),
P = [label(Category,ok(R)) | In].

add_category_min_score(In, Category,Min,P) :-
P = [label(Category,need(Min)) | In].

submit_rule(S) :-
gerrit:default_submit(X),
X =.. [submit | Ls],
gerrit:remove_label(Ls,label('Code-Review',_),NoCR),
add_category_min_score(NoCR,'Code-Review', 4, Labels),
S =.. [submit | Labels].

修改一组项目的submit条件,这些项目必须有相同的parent project,最顶级的parent是All-Project:

git clone <parent project>
git fetch origin refs/meta/config
git branch refs/meta/config
git checkout refs/meta/config
vi rules.pl
git add rules.pl
git commit -m "your message"
git push origin HEAD:refs/meta/config

rules.pl示例,功能和之前一样,入口函数为submit_filter:

% Need two `CodeReview +2` commits to let change submittable
% Ranler Cao  caoran@fiberhome.com 2017/4/25

sum_list([], 0).
sum_list([H | Rest], Sum) :- sum_list(Rest,Tmp), Sum is H + Tmp.

score(Category, Score, User) :-
gerrit:commit_label(label(Category, Score), User),
Score >= 2.

add_category_min_score(In, Category, Min,  P) :-
findall(X, score(Category, X, R), Z),
sum_list(Z, Sum),
Sum >= Min, !,
gerrit:current_user(R),
P = [label(Category,ok(R)) | In].

add_category_min_score(In, Category,Min,P) :-
P = [label(Category,need(Min)) | In].

submit_filter(In, Out) :-
In =.. [submit | Ls],
gerrit:remove_label(Ls,label('Code-Review',_),NoCR),
add_category_min_score(NoCR,'Code-Review', 4, Labels),
Out =.. [submit | Labels].
  • https://searchcode.com/codesearch/view/569473/
  • https://programmermagazine.github.io/201308/htm/article3.html
  • https://gerrit-review.googlesource.com/Documentation/prolog-cookbook.html#SubmitFilter
  • https://groups.google.com/forum/#!topic/repo-discuss/JvvDvZ0q7jk
  • https://groups.google.com/forum/#!topic/repo-discuss/JvvDvZ0q7jk
  • http://www.bluetrainsoftware.com/2014/05/gerrit-2-looks-good-to-me-and-self.html

发表评论