顯示具有 Gerrit 標籤的文章。 顯示所有文章
顯示具有 Gerrit 標籤的文章。 顯示所有文章

2013年5月6日 星期一

Gerrit auto publish and submit

$ ssh -p 29418 yan@yanxen.no-ip.org gerrit query --format JSON --current-patch-set status:open label:V=1 label:R=2 project:RWS_System

# ssh -p 29418 admin@yanxen.no-ip.org gerrit review --submit 9a48b3f46c6ddf6bbdcbe23c349802f6916bf5d1


// run after jenkins build and add comment
$ vi /home/gerrit/review_sites/hooks/comment-added
#!/usr/bin/python

# auto submit after jenkins verified
# for Gerrit 2.5

import json, sys
from subprocess import Popen, PIPE

username = "jenkins"
server = "localhost"

verified_min = 1
reviewed_min = 2

results = Popen([
"ssh", "-p", "29418", username+"@"+server, "gerrit", "query",
"--format", "JSON", "--current-patch-set", "--commit-message",
"--files" , "status:open", "label:V="+str(verified_min), "label:R="+str(reviewed_min)], stdout=PIPE).communicate()[0]

parsed = json.loads(results.split("\n")[0])

if parsed:
    commit = parsed['currentPatchSet']['revision']
    results = Popen([
"ssh", "-p", "29418", username+"@"+server,
"gerrit", "review", "--submit", commit], stdout=PIPE).communicate()[0]




Reference :
From blue skies and oceans — Configuring Gerrit to auto-submit on patch approval

2013年5月2日 星期四

run script after git clone

$ mkdir -p ~/.git/hooks

$ vi ~/.git/hooks/post-checkout
#!/bin/sh                                                                                                                    


echo "Project : $0"
echo "Working on `pwd` ..."

git config remote.origin.push refs/heads/*:refs/for/*


echo "Get Hooks ..."

HOOK_DIR='.git/hooks'

echo "  - commit-msg"
wget -P $HOOK_DIR -q http://yanxen.no-ip.org:8081/tools/hooks/commit-msg

chmod u+x -R $HOOK_DIR

$ chmod u+x -R ~/.git/hooks

$ git clone --template=/home/user/.git ssh://user@gerrit.server:29418/my_project

git-review for Gerrit

$ cd my_project

$ vi .gitreview
[gerrit]
host=gerrit.server
port=29418
project=my_project

$ git review -s

$ echo hello > world
 
$ git add world

$ git commit -m 'hello world'
 
$ git review  // 代替 git push





Reference :
gerrit with jenkins : installation and configuration | Loïc Dachary


Further:
隨手誌: git push到gerrit review server的方法與設定

2013年5月1日 星期三

missing Change-Id in commit message

下載生成 Change-Id 的 hook
$ scp -p -P 29418 user@gerrit.server:hooks/commit-msg .git/hooks/

or 

$ cd .git/hooks ; wget http://gerrit.server:8081/tools/hooks/commit-msg ; chmod u+x commit-msg


重新 commit
$ git commit --amend




Reference :
missing Change-Id in commit message
git - Gerrit error when Change-Id in commit messages are missing - Stack Overflow

Gerrit query verified

command :
$ ssh -p 29418 yan@gerrit.server gerrit query --format JSON --current-patch-set --commit-message --files status:open label:V=1 label:R=2

http :
http://gerrit.server/#/q/is:open+Verified>=1+-Verified<=-1+CodeReview>=1+-CodeReview<=-1+branch:master+reviewer:green+age:3d,n,z


Reference :
Gerrit Code Review - Searching Changes
gerrit query

Useful Gerrit Searches - HPDD Community Space - HPDD Community Wiki

2013年4月30日 星期二

Gerrit Fixing the email address


select * from ACCOUNT_EXTERNAL_IDS;
 
 
 
 
Reference : 
Git, Gerrit Review and Jenkins or Hudson CI Servers 

Gerrit 使用 http 驗証

version : gerrit-full-2.5.2.war

(gerrit)$ ./review_sites/bin/gerrit.sh stop
(gerrit)$ vi ./review_sites/etc/gerrit.config
[gerrit]
        basePath = git
[database]
        type = MYSQL
        hostname = localhost
        database = reviewdb
        username = gerrit
[auth]
        type = HTTP
[sendemail]
        smtpServer = localhost
[container]
        user = gerrit
        javaHome = /usr/lib/jvm/java-6-openjdk-amd64/jre
[sshd]
        listenAddress = *:29418
[httpd]
        listenUrl = proxy-http://127.0.0.1:8081/
[cache]
        directory = cache
(gerrit)$ ./review_sites/bin/gerrit.sh start


# vi /etc/apache2/sites-enabled/000-default

    ProxyRequests Off
    ProxyVia Off
    ProxyPreserveHost On

 
    Order deny,allow
    Allow from all
 


 
    AuthType Basic
    AuthName "Gerrit Code Review"
    Require valid-user
    AuthBasicProvider file
    AuthUserFile /home/gerrit/review_sites/etc/htpasswd_gerrit
 


    ProxyPass / http://127.0.0.1:8081/
#    ProxyPassReverse / http://127.0.0.1:8081/
# /etc/init.d/apache2 restart




Reference :
Gerrit复核服务器搭建简易教程(Ubuntu 12.10)
Chromatic Coder: 架設Gerrit和Git

2013年4月29日 星期一

Push existing git repositories to Gerrit

$ git push ssh://user@gerrit.server:22/home/gerrit/review_sites/git/my_project.git HEAD:refs/heads/master


* 不要向 Gerrit server port 推送 (port 29418) (not using the Gerrit server’s SSH port)




Reference :
One or more refs/for/ names blocks change upload

2012年6月3日 星期日

Specified key was too long; max key length is 1000 bytes

建立索引时,数据库计算key的长度是累加所有Index用到的字段的char长度后再按下面比例乘起来不能超过限定的key长度1000

如果表是UTF8字符集,那索引还是建立不了。




在安裝 Gerrit 時發生了這個問題, 或許創建資料庫時使用就不使用 utf8 改用 latin1 或其他




Reference :
YOYO’S BLOG » Blog Archive » MySQL错误“Specified key was too long; max key length is 1000 bytes”的解决办法

Gerrit 安裝

[Server]
# apt-get install mysql-server mysql-client postfix sun-java6-jre

mysql -u root -p
mysql> CREATE USER 'gerrit'@'localhost' IDENTIFIED BY 'gerrit';
mysql> CREATE DATABASE reviewdb;
mysql> ALTER DATABASE reviewdb charset=latin1;
mysql> GRANT ALL ON reviewdb.* TO 'gerrit'@'localhost';
mysql> FLUSH PRIVILEGES;

# useradd -m gerrit
# su - gerrit

$ wget http://gerrit.googlecode.com/files/gerrit-2.4.war
$ chmod 744 gerrit-2.2.1.war
$ java -jar gerrit-2.2.1.war init -d review_sites

*** Gerrit Code Review 2.4
***


*** Git Repositories
***

Location of Git repositories   [git]:

*** SQL Database
***

Database server type           [MYSQL/?]:
Server hostname                [localhost]:
Server port                    [(MYSQL default)]:
Database name                  [reviewdb]:
Database username              [root]: gerrit
Change gerrit's password       [y/N]? y
gerrit's password              :
              confirm password :

*** User Authentication
***

Authentication method          [OPENID/?]:

*** Email Delivery
***

SMTP server hostname           [localhost]:
SMTP server port               [(default)]:
SMTP encryption                [NONE/?]:
SMTP username                  :

*** Container Process
***

Run as                         [gerrit]:
Java runtime                   [/usr/lib/jvm/java-6-sun-1.6.0.24/jre]:
Upgrade /home/gerrit/review_sites/bin/gerrit.war [Y/n]?
Copying gerrit.war to /home/gerrit/review_sites/bin/gerrit.war


*** SSH Daemon
***

Listen on address              [*]: Listen on port                 [29418]:

*** HTTP Daemon
***

Behind reverse proxy           [y/N]?
Use SSL (https://)             [y/N]?
Listen on address              [*]:
Listen on port                 [8080]:
Canonical URL                  [http://localhost:8080/]:

Initialized /home/gerrit/review_sites

$ ~/review_sites/bin/gerrit.sh restart


 [Client]
進入 Gerrit 網頁 http://localhost:8080/
Registered the first user with openid. // 註冊的第一位使用者將自動成為主管理員
Add SSH Public Keys
 
$ ssh -p 29418 yan@your_domain
  ****    Welcome to Gerrit Code Review    ****

  Hi yan, you have successfully connected over SSH.

  Unfortunately, interactive shells are disabled.
  To clone a hosted Git repository, use:

  git clone ssh://yan@localhost:29418/REPOSITORY_NAME.git

Connection to localhost closed.


$ ssh -p 29418 yan@localhost gerrit create-project -n sandbox
$ git clone ssh://yan@localhost:29418/sandbox.git 
Cloning into 'sandbox'...
warning: remote HEAD refers to nonexistent ref, unable to checkout.
$ cd sandbox
$ touch README
$ git add *
$ git commit
$ git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 202 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Processing changes: refs: 1, done   
To ssh://yan@localhost:29418/sandbox.git
 ! [remote rejected] master -> master (can not create new references)
error: failed to push some refs to 'ssh://yan@localhost:29418/sandbox.git'

原因:Gerrit不希望我们直接覆写Git代码库中的任何分支

$ git config remote.origin.push refs/heads/*:refs/for/*
or
$ git config remote.origin.push HEAD:refs/for/master

$ git push origin


* 專案管理可用 git-review 工具代替


進入網頁 http://localhost:8080/ 選單 My -> Changes 即可看到待審核的提交






Reference :
Cherry-picking Pearls in San Francisco: My take on installing gerrit (git code review tool) on ubuntu
Gerrit unter Ubuntu installieren | seeseekey.net
InfoQ: Git、Gerrit与Jenkins/Hudson CI服务器
John Hsing's Blog: 初试 Gerrit


Further :
隨手誌: git push到gerrit review server的方法與設定