Setting-up-Gerrit: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
(swap redirects)
 
(15 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=Setting Up Gerrit=
#REDIRECT [[Setting up Gerrit]]
 
==How to get started – Gerrit registration==
 
# Create an account in the [https://bugreports.qt.io/ Qt bug tracker] ''[bugreports.qt.io]'' (also known as <span class="caps">JIRA</span>)
# Go to https://codereview.qt.io and log in with your Qt bug tracker credentials
#* '''Note''': Gerrit usernames are case-sensitive, but <span class="caps">JIRA</span> 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 “Settings” -&gt; “Contact Information” and register your email address. You will receive a confirmation email; click on the link inside to finalize your registration.
#* '''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” -&gt; “<span class="caps">SSH</span> Public Keys” and upload your [https://help.github.com/articles/generating-ssh-keys public <span class="caps">SSH</span> Key] ''[help.github.com]'' , configure username (under contact information), upload public [https://help.github.com/articles/generating-ssh-keys <span class="caps">SSH</span> key] ''[help.github.com]''
# If you are behind a firewall that blocks <span class="caps">SSH</span> access:
## Go to “Settings” -&gt; “<span class="caps">HTTP</span> Password”
## Click “Generate Password”
## Add the following line to your <code>~/.netrc</code> (Windows: <code>​%USERPROFILE%\_netrc</code>):<br />
 
==Local Setup==
 
Configure <span class="caps">SSH</span> properly (the <span class="caps">URL</span>s below rely on this). Add this to your <code>~/.ssh/config</code> (Windows: <code>C:\Users\%USERNAME%\.ssh\config</code>):
 
'''<span class="caps">NOTE</span>:''' 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
 
or by downloading the file via browser: [http://codereview.qt.io/tools/hooks/commit-msg commit-msg] ''[codereview.qt.io]'' 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 [https://qt.gitorious.org/qt/qtrepotools qtrepotools] ''[qt.gitorious.org]'' repository. This gives you the checks of the [[Early-Warning-System|Sanity Bot]] locally. To do this, save the script<br /> into each &lt;path to git clone&gt;\.git\hooks\post-commit
 
'''<span class="caps">NOTE</span>:''' Starting with git 1.7.8, if <code>&lt;module name&gt;/.git</code> contains <code>gitdir: ../.git/modules/&lt;module name&gt;</code>, you need to put the submodule hooks in <code>.git/modules/&lt;module name&gt;/hooks</code> instead of <code>&lt;module name&gt;/.git/hooks</code>.
 
===Configuring Git===
 
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
 
to automatically get <span class="caps">CRLF</span> line endings which are suitable for the native tools, and Unix users ''should'' use
 
(this is a safety measure for the case where files with <span class="caps">CRLF</span> line endings get into the file system – 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:
 
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:
 
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 stat</code> and <code>git commit</code>, even if this is somewhat slower (especially on Windows):
 
Git has a somewhat stupid default that <code>git push</code> will push ''all'' branches to the upstream repository, which is almost never what you want. To fix this, use:
 
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>git pull</code> will show a nice diffstat, so you get an overview of the changes from upstream. <code>git pull —rebase</code> does not do that by default. But you want it:
 
To get nicely colored patches (from <code>git diff</code>, <code>git log -p</code>, <code>git show</code>, etc.), use this:
 
Git supports aliases which you can use to save yourself some typing. For example, these (any similarity with subversion command aliases is purely accidental ;)):
 
===Using Existing clones===
 
Add a <code>gerrit</code> remote pointing to codereview.
 
If you are behind a <span class="caps">SSH</span>-blocking firewall, use the https protocol:
 
For Qt 4.8, use
 
If you are behind a <span class="caps">SSH</span>-blocking firewall, use the https protocol:
 
===Cloning repositories===
 
You should clone from the repositories hosted at [http://qt.gitorious.org/ qt.gitorious.org] ''[qt.gitorious.org]'' or [https://github.com/qtproject/ github.com/qtproject] ''[github.com]'' and track changes from there in order to keep the load on Gerrit down.
 
====Cloning Qt4====
 
For [http://qt.gitorious.org/ qt.gitorious.org] ''[qt.gitorious.org]'' :
 
For [https://github.com/qtproject/ github.com/qtproject] ''[github.com]'' :
 
Note that 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 [http://qt.gitorious.org/ qt.gitorious.org] ''[qt.gitorious.org]'' :
 
For [https://github.com/qtproject/ github.com/qtproject] ''[github.com]'' :
 
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 <span class="caps">URL</span>s (like “../qtbase.git”) in the .gitmodules file.<br /> If you make a clone of git://gitorious.org/qt/qt5 in gitorious as git://gitorious.org/~&lt;username&gt;/qt/&lt;cloned-repository-name&gt;.git the init-repository script will not work.
 
A <span class="caps">URL</span> rewrite rule has to be added to the .gitconfig file:<br />
 
====Cloning Qt Creator====
 
For [http://qt.gitorious.org/ qt.gitorious.org] ''[qt.gitorious.org]'' :
 
For [https://github.com/qtproject/ github.com/qtproject] ''[github.com]'' :
 
===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):
 
You can’t push directly to a branch. So you need to create a review. “refs/for/5.4” means “please submit this as a review for branch 5.4”. <br /> It is recommended you use the git-gpush script from the [https://qt.gitorious.org/qt/qtrepotools qtrepotools repository] ''[qt.gitorious.org]''.
 
===Categories:===
 
* [[:Category:Developing Qt|Developing_Qt]]
** [[:Category:Developing Qt::Instructions|Instructions]]

Latest revision as of 17:02, 27 February 2015

Redirect to: