使用 Gerrit 审查代码

Gerrit Workflow

Alt none

启动 Gerrit

java -jar gerrit.war init -d /path/to/your/gerrit_application_directory

Set Permission(Nginx)

Import Exist Project into gerrit

Create GitReview File

touch .gitreview

Edit gitreview file:

[gerrit]
host=192.168.1.109
port=29418
project=TestGerrit.git

Replication Configuration

cd $GERRIT_HOME/etc
touch replication.config

Edit replication.config file:

[remote "TestGerrit"]
url = ssh://[email protected]:PORT/${name}.git

Restart Gerrit

gerrit.sh  restart

Replication Plugin log file is located at $GERRIT_HOME/log/replication_log Alt none

Use git review command

Install git-review

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
brew install git-review
  git add files
  git commit
  git-review

Browse your commits

Alt none

Use git command

git add files
git commit
git push gerrit <branch>

Git repository configure:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = ssh://[email protected]:PORT/TestGerrit
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[remote "gerrit"]
    url = ssh://[email protected]:PORT/TestGerrit.git
    fetch = +refs/heads/*:refs/remotes/origin/*
    push = refs/heads/*:refs/for/*
[branch "DEV"]
    remote = origin
    merge = refs/heads/DEV
    push = refs/heads/DEV:refs/for/DEV

ref: https://review.openstack.org/Documentation/intro-quick.html