0%

(MAC)(Git) Gerrit Server

Git on MAC [By Homebrew]

  1. Install XCode for (GCC tools)

  2. Install Homebrew

     ruby -e "$(curl -fsSL https://gist.github.com/raw/323731/install_homebrew.rb)"
    
  3. Install Git (By homebrew)

     brew install git
    
  4. brew list

     brew list git
    

Git on MAC [By Macports]

  1. Install Macports

  2. Install Git (By Macports)

     sudo port install git-core
    

Gerrit on MAC:

  1. Install MYSQL

    • Get Mysql from official site (Mysql Community version)
  2. Get Mysql Java Connector (Connector/J, .jar)

    • Copy to /Library/Java/Extensions/
  3. Setup Mysql-DB

     mysql -u root -p
     CREATE USER 'gerrit'@'localhost' IDENTIFIED BY 'password';
     CREATE DATABASE reviewdb;
     ALTER DATABASE reviewdb charset=latin1;
     GRANT ALL ON reviewdb.* TO 'gerrit'@'localhost';
     FLUSH PRIVILEGES;
    
  4. Get Gerrit from http://code.google.com/p/gerrit/downloads/list

  5. Install Gerrit

     java -jar gerrit.war init -d review_sit
    
  6. Setup Gerrit Authentication by Http

  7. Setup Apache /etc/apache2/httpd.conf as:

     Listen 9090
     #Gerrit Reverse Apache for Authentication
     <VirtualHost *:9090>
       ServerName Gerrit
       ProxyRequests Off
       ProxyVia Off
       ProxyPreserveHost On
       <Proxy *>
             Order deny,allow
             Allow from all
       </Proxy>
       <Location /gerrit/login/>
          AuthType Basic
          AuthName "Gerrit Code Review"
          AuthBasicProvider file
          AuthUserFile /Users/shiunyi/gerrit/review_site/etc/gerrit.passwd
          Require valid-user
       </Location>
       ProxyPass /gerrit/ http://localhost:8081/gerrit/
     </VirtualHost>
    
  8. Setup account of Gerrit

     htpasswd -m /Users/shiunyi/gerrit/review_site/etc/gerrit.passwd NeilLee
    
  9. Start Gerrit

     gerrit/review_site/bin/gerrit.sh start
    
  10. Web login

    http://192.168.11.5:9090/gerrit/

  11. gerrit.config

    [gerrit]
            basePath = git
    [database]
            type = MYSQL
            hostname = localhost
            database = reviewdb
            username = gerrit
    [auth]
            type = HTTP
    [sendemail]
            enable = true
            smtpServer = smtp.gmail.com
            smtpServerPort = 465
            smtpEncryption = SSL
            smtpUser = user@gmail.com
            smtpPass = 
            user = gerrit
            javaHome = /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    [sshd]
            listenAddress = *:29418
    [httpd]
            listenUrl = proxy-http://*:8081/gerrit
    [cache]
            directory = cache
    
  12. Using Gerrit

    • SSH authentication

      • client:

          ssh-keygen -t rsa
          pbcopy < ~/.ssh/id_rsa.pub
        
    • Gerrit server:

      • Add your ssh key to gerrit
      • Restart gerrit server
    • Gerrit client:

        ssh -p 29418 <your username in gerrit>@<gerrit's IP>