Setting-up-Gerrit: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
(swap redirects)
 
(14 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= Setting Up Gerrit =
#REDIRECT [[Setting up Gerrit]]
 
[toc align_right="yes" depth="3"]All projects under the Qt Open Governance umbrella are hosted at "codereview.qt.io":http://codereview.qt.io. These repositories are mirrored on "Gitorious":http://qt.gitorious.org.
 
== How to get started - Gerrit registration ==
 
# Create 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 attempt to log into Gerrit with different capitalizations, you will end up with multiple accounts.
# Go to the Settings page: https://codereview.qt.io/settings/
# Go to &quot;Settings&amp;quot; <s>&gt; &quot;Contact Information&amp;quot; and register your email address. You will receive a confirmation email; click on the link inside to finalize your registration.<br />'''''' '''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)<br /># Go to &quot;Settings&amp;quot;</s>&gt; &quot;SSH Public Keys&amp;quot; and upload your &quot;public SSH Key&amp;quot;:https://help.github.com/articles/generating-ssh-keys , configure username (under contact information), upload public &quot;SSH key&amp;quot;:https://help.github.com/articles/generating-ssh-keys
# If you are behind a firewall that blocks SSH access:
## Go to &quot;Settings&amp;quot; -&gt; &quot;HTTP Password&amp;quot;
## Click &quot;Generate Password&amp;quot;
## Add the following line to your &lt;code&amp;gt;<sub>/.netrc&amp;lt;/code&amp;gt; (Windows: &lt;code&amp;gt;​%USERPROFILE%netrc&amp;lt;/code&amp;gt;):<br /><code><br />machine codereview.qt.io login &lt;Gerrit username&amp;gt; password &lt;Generated password&amp;gt;<br /></code>
 
<br />h2. Local Setup
<br />Configure SSH properly (the URLs below rely on this). Add this to your &lt;code&amp;gt;</sub>/.ssh/config&amp;lt;/code&amp;gt; (Windows: &lt;code&amp;gt;C:USERNAME%sh\config&amp;lt;/code&amp;gt;):
 
<code><br /> Host codereview.qt.io<br /> Port 29418<br /> User &lt;Gerrit/Jira username&amp;gt;<br /></code>
 
'''NOTE:''' The following steps need to be applied to every clone:
 
Install the hook generating Commit-Id files into your top level project directory, as well as all sub-repositories (e.g. qtbase.git) either through
 
<code><br /> $ scp <s>p codereview.qt.io:hooks/commit-msg .git/hooks<br /></code>
<br />or by downloading the file via browser: &quot;commit-msg&amp;quot;:http://codereview.qt.io/tools/hooks/commit-msg and putting it into the &lt;code&amp;gt;.git/hooks&amp;lt;/code&amp;gt; directory (make sure it is executable).
<br />It is recommended to install the git_post_commit_hook from the &quot;qtrepotools&amp;quot;: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<br /><code><br />#! /bin/sh<br />exec &quot;&lt;path to git clone&amp;gt;/qtrepotools/git-hooks/git_post_commit_hook&amp;quot; &quot;$</code>&quot;<br /><code><br />into each &lt;path to git clone&amp;gt;it\hooks\post-commit
<br />'''NOTE:''' Starting with git 1.7.8, if &lt;code&amp;gt;&lt;module name&amp;gt;/.git&amp;lt;/code&amp;gt; contains &lt;code&amp;gt;gitdir: ../.git/modules/&amp;lt;module name&amp;gt;&lt;/code&amp;gt;, you need to put the submodule hooks in &lt;code&amp;gt;.git/modules/&amp;lt;module name&amp;gt;/hooks&amp;lt;/code&amp;gt; instead of &lt;code&amp;gt;&lt;module name&amp;gt;/.git/hooks&amp;lt;/code&amp;gt;.
<br />h3. Configuring Git
<br />We are developing in a heterogeneous environment with both Unix and Windows machines. Therefore it is imperative to have all files in the repository in the canonical LF-only format. Therefore, Windows users '''must''' run
<br /></code><br /> $ git config —global core.autocrlf true<br /><code>
<br />to automatically get CRLF line endings which are suitable for the native tools, and Unix users ''should'' use
<br /></code><br /> $ git config —global core.autocrlf input<br /><code>
<br />(this is a safety measure for the case where files with CRLF line endings get into the file system</s> this can happen when archives are unpacked, attachments saved, etc.).
 
To be able to create commits which can be pushed to the server, you need to set up your committer information correctly:
 
</code><br /> $ git config —global user.name &quot;Your Name&amp;quot;<br /> $ git config —global user.email &quot;me<code>example.com&amp;quot;<br /></code>
 
Please do not use nicknames or pseudonyms instead of the real name unless you have really good reasons.<br />Gerrit will not accept your commits unless the committer information matches the email address(es) you registered.
 
To facilitate following the style guide for commit messages, it is recommended to install the Qt commit message template:
 
<code><br /> $ git config —global commit.template &lt;path to qt5.git or qt.git&amp;gt;/.commit-template<br /></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 &lt;code&amp;gt;git stat&amp;lt;/code&amp;gt; and &lt;code&amp;gt;git commit&amp;lt;/code&amp;gt;, even if this is somewhat slower (especially on Windows):
 
<code><br /> $ git config —global status.showuntrackedfiles all<br /></code>
 
Git has a somewhat stupid default that &lt;code&amp;gt;git push&amp;lt;/code&amp;gt; will push ''all'' branches to the upstream repository, which is almost never what you want. To fix this, use:
 
<code><br /> $ git config —global push.default tracking<br /></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 private clones.
 
Sometimes it is necessary to resolve the same conflicts multiple times. Git has the ability to record and replay conflict resolutions automatically, but - surprise surprise - it is not enabled by default. To fix it, run:
 
<code><br /> $ git config —global rerere.enabled true<br /> $ git config —global rerere.autoupdate true # this saves you the git add, but you should verify the result with git diff —staged<br /></code>
 
&lt;code&amp;gt;git pull&amp;lt;/code&amp;gt; will show a nice diffstat, so you get an overview of the changes from upstream. &lt;code&amp;gt;git pull —rebase&amp;lt;/code&amp;gt; does not do that by default. But you want it:
 
<code><br /> $ git config —global rebase.stat true<br /></code>
 
To get nicely colored patches (from &lt;code&amp;gt;git diff&amp;lt;/code&amp;gt;, &lt;code&amp;gt;git log -p&amp;lt;/code&amp;gt;, &lt;code&amp;gt;git show&amp;lt;/code&amp;gt;, etc.), use this:
 
<code><br /> $ git config —global color.ui auto<br /> $ git config —global core.pager &quot;less -FRSX&amp;quot;<br /></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><br /> $ git config —global alias.di diff<br /> $ git config —global alias.ci commit<br /> $ git config —global alias.co checkout<br /> $ git config —global alias.ann blame<br /> $ git config —global alias.st status<br /></code>
 
=== Using Existing clones ===
 
Add a &lt;code&amp;gt;gerrit&amp;lt;/code&amp;gt; remote pointing to codereview.
 
<code><br /> $ git remote add gerrit ssh://codereview.qt.io/qt/&amp;lt;qt5 or the submodule name you have checked out&amp;gt;<br /></code>
 
If you are behind a SSH-blocking firewall, use the https protocol:
 
<code><br /> $ git remote add gerrit https://codereview.qt.io/p/qt/&amp;lt;qt5 or the submodule name you have checked out&amp;gt;<br /></code>
 
For Qt 4.8, use
 
<code><br /> $ git remote add gerrit ssh://codereview.qt.io/qt/qt<br /></code>
 
If you are behind a SSH-blocking firewall, use the https protocol:
 
<code><br /> $ git remote add gerrit https://codereview.qt.io/p/qt/qt<br /></code>
 
=== Cloning repositories ===
 
You should clone from the repositories hosted at &quot;qt.gitorious.org&amp;quot;:http://qt.gitorious.org/ or &quot;github.com/qtproject&amp;quot;:https://github.com/qtproject/ and track changes from there in order to keep the load on Gerrit down.
 
==== Cloning Qt4 ====
 
For &quot;qt.gitorious.org&amp;quot;:http://qt.gitorious.org/ :
 
<code><br /> $ git clone git://gitorious.org/qt/qt.git<br /></code>
 
For &quot;github.com/qtproject&amp;quot;:https://github.com/qtproject/ :
 
<code><br /> $ git clone git://github.com/qtproject/qt.git<br /></code>
 
Note that Qt4 does not have a &lt;code&amp;gt;master&amp;lt;/code&amp;gt; branch (since no 4.9 is planned). So, you should push changes to the &lt;code&amp;gt;4.8&amp;lt;/code&amp;gt; branch.
 
==== Cloning Qt5 ====
 
For &quot;qt.gitorious.org&amp;quot;:http://qt.gitorious.org/ :
 
<code><br /> $ git clone git://gitorious.org/qt/qt5.git<br /></code>
 
For &quot;github.com/qtproject&amp;quot;:https://github.com/qtproject/ :
 
<code><br /> $ git clone git://github.com/qtproject/qt5.git<br /> $ cd qt5<br /> $ ./init-repository -f —no-webkit —mirror git://github.com/qtproject<br /></code>
 
It is recommended that, 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.
 
Alternatively, individual Qt5 submodules can be manually cloned as well. Follow Using Existing Clones above after cloning.
 
Note that Qt 5 submodules have been changed from absolute to relative URLs (like &quot;../qtbase.git&amp;quot;) in the .gitmodules file.<br />If you make a clone of git://gitorious.org/qt/qt5 in gitorious as git://gitorious.org/~&lt;username&amp;gt;/qt/&amp;lt;cloned-repository-name&amp;gt;.git the init-repository script will not work.
 
A URL rewrite rule has to be added to the .gitconfig file:<br /><code><br />[url &quot;git://gitorious.org/qt/&amp;quot;]<br /> insteadOf = git://gitorious.org/~&lt;username&amp;gt;/qt/<br /></code>
 
==== Cloning Qt Creator ====
 
For &quot;qt.gitorious.org&amp;quot;:http://qt.gitorious.org/ :
 
<code><br /> $ git clone git://gitorious.org/qt-creator/qt-creator.git<br /></code>
 
For &quot;github.com/qtproject&amp;quot;:https://github.com/qtproject/ :
 
<code><br /> $ git clone git://github.com/qtproject/qt-creator.git<br /></code>
 
=== Pushing your local changes to gerrit ===
 
After you have committed your changes locally, you can push them to Gerrit like this (for example, &lt;code&amp;gt;5.4&amp;lt;/code&amp;gt; branch):
 
<code><br /> $ git push gerrit HEAD:refs/for/5.4<br /></code>
 
You can't push directly to a branch. So you need to create a review. &quot;refs/for/5.4&amp;quot; means &quot;please submit this as a review for branch 5.4&amp;quot;.

Latest revision as of 17:02, 27 February 2015

Redirect to: