Menu Home

Use Gerrit

Gerrit Workflow

Set Permission(Nginx)

  • Create password file
  • htpasswd -c /path/gerrit.password username
  • Add New User
  • htpasswd -m /path/gerrit.password username
  • Nginx Configuration
  • server {
         listen *:80;
         server_name gerrit;
         allow   all;
         deny    all;
    
         auth_basic "Welcomme to Gerrit !";
         auth_basic_user_file /path/gerrit.password;
    
         location / {
            proxy_pass  http://127.0.0.1:8080;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header Host $host;
         }
    }

Import Exist Project into gerrit

  • Checkout Exist Project
  • cd $GERRIT_HOME/git
    git clone --bare ssh:[email protected]:PORT/TestGerrit.git
    

  • Restart Gerrit
  • gerrit.sh  restart
  • Refresh Gerrit Projects Page

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

Use git review command

Install git-review

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

Browse your commits

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

Categories: 未分类

Tagged as:

lnmcc