User Tools

Site Tools


gerrit_tutorial

This is an old revision of the document!


Overview

Tutorial for Gerrit, using mediawiki Gerrit repo.

Preparation

  • Install Git (duh)
  • Generate local SSH keys
  • Create account at Mediawiki, add SSH keys
  • Install git-review package on Linux

Test access with (should see):

$ ssh -p 29418 rpjday@gerrit.wikimedia.org

  ****    Welcome to Gerrit Code Review    ****

  Hi Robert P. J. Day, you have successfully connected over SSH.

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

  git clone ssh://rpjday@gerrit.wikimedia.org:29418/REPOSITORY_NAME.git

Connection to gerrit.wikimedia.org closed.
$

Cloning the test repo

Clone a test repo:

$ git clone ssh://rpjday@gerrit.wikimedia.org:29418/mediawiki/extensions/examples
Cloning into 'examples'...
remote: Counting objects: 44, done
remote: Finding sources: 100% (4/4)
remote: Getting sizes: 100% (3/3)
remote: Compressing objects: 100% (127443/127443)
remote: Total 1342 (delta 0), reused 1339 (delta 0)
Receiving objects: 100% (1342/1342), 305.93 KiB | 3.00 MiB/s, done.
Resolving deltas: 100% (889/889), done.
$

The .git/config file:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = ssh://rpjday@gerrit.wikimedia.org:29418/mediawiki/extensions/examples
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

The .gitreview file:

[gerrit]
host=gerrit.wikimedia.org
port=29418
project=mediawiki/extensions/examples.git
track=1

Finally, there are no configured hooks:

$ ls -1 .git/hooks
applypatch-msg.sample
commit-msg.sample
fsmonitor-watchman.sample
post-update.sample
pre-applypatch.sample
pre-commit.sample
pre-merge-commit.sample
prepare-commit-msg.sample
pre-push.sample
pre-rebase.sample
pre-receive.sample
update.sample
$

Configuring git-review

Verify remotes:

$ git remote -v
origin	ssh://rpjday@gerrit.wikimedia.org:29418/mediawiki/extensions/examples (fetch)
origin	ssh://rpjday@gerrit.wikimedia.org:29418/mediawiki/extensions/examples (push)
$

Configuring git-review for origin

Point git-review at origin:

$ git config --global gitreview.remote origin

Adds .gitconfig info:

gitreview.remote=origin

git-review --setup

Set up git-review:

$ git review -s
gerrit_tutorial.1587491420.txt.gz · Last modified: 2020/04/21 17:50 by rpjday