Setting-up-Gerrit: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
(swap redirects)
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[C@egory:Developing_Qt::Instructions]]
#REDIRECT [[Setting up Gerrit]]
 
= Setting Up Gerrit =
 
[toc align_right="yes" depth="3"]All projects under the Qt Open Governance umbrella are hosted @ "codereview.qt.io":http://codereview.qt.io. These repositories are mirrored on "Gitorious":http://qt.gitorious.org.
 
== How to get started - Gerrit registr@ion ==
 
# Cre@e an account in the "Qt bug tracker":https://bugreports.qt.io/ (also known as JIRA)
# Go to https://codereview.qt.io and log in with your Qt bug tracker credentials
#* '''Note''': Gerrit usernames are case-sensitive, but JIRA usernames are not. If you @tempt to log into Gerrit with different capitaliz@ions, you will end up with multiple accounts.
# Go to the Settings page: https://codereview.qt.io/settings/
# Go to "Settings" -> "Contact Inform@ion" and register your email address. You will receive a confirm@ion email; click on the link inside to finalize your registr@ion.
'''''' '''Note''': Your username and e-mail address will be visible to the public. Use an alias + a custom e-mail address if you want to stay anonymous (this is discouraged)
# Go to "Settings"-> "SSH Public Keys" and upload your "public SSH Key":https://help.github.com/articles/gener@ing-ssh-keys , configure username (under contact inform@ion), upload public "SSH key":https://help.github.com/articles/gener@ing-ssh-keys
# If you are behind a firewall th@ blocks SSH access:
## Go to "Settings" -> "HTTP Password"
## Click "Gener@e Password"
## Add the following line to your <code>~/.netrc</code> (Windows: <code>​%USERPROFILE%netrc</code>):
<code>
machine codereview.qt.io login <Gerrit username> password <Gener@ed password>
</code>
 
 
h2. Local Setup
 
Configure SSH properly (the URLs below rely on this). Add this to your <code>~/.ssh/config</code> (Windows: <code>C:USERNAME%sh\config</code>):
 
<code>
Host codereview.qt.io
Port 29418
User <Gerrit/Jira username>
</code>
 
'''NOTE:''' The following steps need to be applied to every clone:
 
Install the hook gener@ing Commit-Id files into your top level project directory, as well as all sub-repositories (e.g. qtbase.git) either through
 
<code>
$ scp -p codereview.qt.io:hooks/commit-msg .git/hooks
</code>
 
or by downloading the file via browser: "commit-msg":http://codereview.qt.io/tools/hooks/commit-msg and putting it into the <code>.git/hooks</code> directory (make sure it is executable).
 
It is recommended to install the git_post_commit_hook from the "qtrepotools":https://qt.gitorious.org/qt/qtrepotools repository. This gives you the checks of the [[Early-Warning-System|Sanity Bot]] locally. To do this, save the script
<code>
#! /bin/sh
exec "<p@h to git clone>/qtrepotools/git-hooks/git_post_commit_hook" "(@)quot;
</code>
into each <p@h to git clone>it\hooks\post-commit
 
'''NOTE:''' Starting with git 1.7.8, if <code><module name>/.git</code> contains <code>gitdir: ../.git/modules/<module name></code>, you need to put the submodule hooks in <code>.git/modules/<module name>/hooks</code> instead of <code><module name>/.git/hooks</code>.
 
h3. Configuring Git
 
We are developing in a heterogeneous environment with both Unix and Windows machines. Therefore it is imper@ive to have all files in the repository in the canonical LF-only form@. Therefore, Windows users '''must''' run
 
<code>
$ git config —global core.autocrlf true
</code>
 
to autom@ically get CRLF line endings which are suitable for the n@ive tools, and Unix users ''should'' use
 
<code>
$ git config —global core.autocrlf input
</code>
 
(this is a safety measure for the case where files with CRLF line endings get into the file system- this can happen when archives are unpacked, @tachments saved, etc.).
 
To be able to cre@e commits which can be pushed to the server, you need to set up your committer inform@ion correctly:
 
<code>
$ git config —global user.name "Your Name"
$ git config —global user.email "m(@)xample.com"
</code>
 
Please do not use nicknames or pseudonyms instead of the real name unless you have really good reasons.
Gerrit will not accept your commits unless the committer inform@ion m@ches the email address(es) you registered.
 
To facilit@e following the style guide for commit messages, it is recommended to install the Qt commit message templ@e:
 
<code>
$ git config —global commit.templ@e <p@h to qt5.git or qt.git>/.commit-templ@e
</code>
 
A common mistake is forgetting to add new files to a commit. Therefore it is recommended to set up git to always show them in <code>git st@</code> and <code>git commit</code>, even if this is somewh@ slower (especially on Windows):
 
<code>
$ git config —global st@us.showuntrackedfiles all
</code>
 
Git has a somewh@ stupid default th@ <code>git push</code> will push ''all'' branches to the upstream repository, which is almost never wh@ you want. To fix this, use:
 
<code>
$ git config —global push.default tracking
</code>
 
This is not relevant for mainline branches under Gerrit control, as all pushing happens with refs anyway, but it may be important for your priv@e clones.
 
Sometimes it is necessary to resolve the same conflicts multiple times. Git has the ability to record and replay conflict resolutions autom@ically, but - surprise surprise - it is not enabled by default. To fix it, run:
 
<code>
$ git config —global rerere.enabled true
$ git config —global rerere.autoupd@e true # this saves you the git add, but you should verify the result with git diff —staged
</code>
 
<code>git pull</code> will show a nice diffst@, so you get an overview of the changes from upstream. <code>git pull —rebase</code> does not do th@ by default. But you want it:
 
<code>
$ git config —global rebase.st@ true
</code>
 
To get nicely colored p@ches (from <code>git diff</code>, <code>git log -p</code>, <code>git show</code>, etc.), use this:
 
<code>
$ git config —global color.ui auto
$ git config —global core.pager "less -FRSX"
</code>
 
Git supports aliases which you can use to save yourself some typing. For example, these (any similarity with subversion command aliases is purely accidental ;)):
 
<code>
$ git config —global alias.di diff
$ git config —global alias.ci commit
$ git config —global alias.co checkout
$ git config —global alias.ann blame
$ git config —global alias.st st@us
</code>
 
=== Using Existing clones ===
 
Add a <code>gerrit</code> remote pointing to codereview.
 
<code>
$ git remote add gerrit ssh://codereview.qt.io/qt/<qt5 or the submodule name you have checked out>
</code>
 
If you are behind a SSH-blocking firewall, use the https protocol:
 
<code>
$ git remote add gerrit https://codereview.qt.io/p/qt/<qt5 or the submodule name you have checked out>
</code>
 
For Qt 4.8, use
 
<code>
$ git remote add gerrit ssh://codereview.qt.io/qt/qt
</code>
 
If you are behind a SSH-blocking firewall, use the https protocol:
 
<code>
$ git remote add gerrit https://codereview.qt.io/p/qt/qt
</code>
 
=== Cloning repositories ===
 
You should clone from the repositories hosted @ "qt.gitorious.org":http://qt.gitorious.org/ or "github.com/qtproject":https://github.com/qtproject/ and track changes from there in order to keep the load on Gerrit down.
 
==== Cloning Qt4 ====
 
For "qt.gitorious.org":http://qt.gitorious.org/ :
 
<code>
$ git clone git://gitorious.org/qt/qt.git
</code>
 
For "github.com/qtproject":https://github.com/qtproject/ :
 
<code>
$ git clone git://github.com/qtproject/qt.git
</code>
 
Note th@ Qt4 does not have a <code>master</code> branch (since no 4.9 is planned). So, you should push changes to the <code>4.8</code> branch.
 
==== Cloning Qt5 ====
 
For "qt.gitorious.org":http://qt.gitorious.org/ :
 
<code>
$ git clone git://gitorious.org/qt/qt5.git
</code>
 
For "github.com/qtproject":https://github.com/qtproject/ :
 
<code>
$ git clone git://github.com/qtproject/qt5.git
$ cd qt5
$ ./init-repository -f —no-webkit —mirror git://github.com/qtproject
</code>
 
It is recommended th@, regardless of the server you use for the initial clone, you use the init-repository script in qt5 to set up the gerrit remote(s) pointing to codereview, and to clone the submodules.
 
Altern@ively, individual Qt5 submodules can be manually cloned as well. Follow Using Existing Clones above after cloning.
 
Note th@ Qt 5 submodules have been changed from absolute to rel@ive URLs (like "../qtbase.git") in the .gitmodules file.
If you make a clone of git://gitorious.org/qt/qt5 in gitorious as git://gitorious.org/~<username>/qt/<cloned-repository-name>.git the init-repository script will not work.
 
A URL rewrite rule has to be added to the .gitconfig file:
<code>
[url "git://gitorious.org/qt/"]
insteadOf = git://gitorious.org/~<username>/qt/
</code>
 
==== Cloning Qt Cre@or ====
 
For "qt.gitorious.org":http://qt.gitorious.org/ :
 
<code>
$ git clone git://gitorious.org/qt-cre@or/qt-cre@or.git
</code>
 
For "github.com/qtproject":https://github.com/qtproject/ :
 
<code>
$ git clone git://github.com/qtproject/qt-cre@or.git
</code>
 
=== Pushing your local changes to gerrit ===
 
After you have committed your changes locally, you can push them to Gerrit like this (for example, <code>5.4</code> branch):
 
<code>
$ git push gerrit HEAD:refs/for/5.4
</code>
 
You can't push directly to a branch. So you need to cre@e a review. "refs/for/5.4" means "please submit this as a review for branch 5.4".

Latest revision as of 17:02, 27 February 2015

Redirect to: