Setting-up-Gerrit: Difference between revisions
No edit summary |
No edit summary |
||
Line 3: | Line 3: | ||
= Setting Up Gerrit = | = Setting Up Gerrit = | ||
[toc align_right= | [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 == | == How to get started - Gerrit registration == | ||
# Create an account in the | # 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 | # 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. | #* '''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 the Settings page: https://codereview.qt.io/settings/ | ||
# Go to | # Go to "Settings" -> "Contact Information" 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 "Settings"-> "SSH Public Keys" and upload your "public SSH Key":https://help.github.com/articles/generating-ssh-keys , configure username (under contact information), upload public "SSH key":https://help.github.com/articles/generating-ssh-keys | ||
# If you are behind a firewall that blocks SSH access: | # If you are behind a firewall that blocks SSH access: | ||
## Go to | ## Go to "Settings" -> "HTTP Password" | ||
## Click | ## Click "Generate Password" | ||
## Add the following line to your | ## Add the following line to your <code>~/.netrc</code> (Windows: <code>%USERPROFILE%netrc</code>):<br /><code><br />machine codereview.qt.io login <Gerrit username> password <Generated password><br /></code> | ||
<br />h2. Local Setup | <br />h2. Local Setup | ||
<br />Configure SSH properly (the URLs below rely on this). Add this to your | <br />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><br /> Host codereview.qt.io<br /> Port 29418<br /> User | <code><br /> Host codereview.qt.io<br /> Port 29418<br /> User <Gerrit/Jira username><br /></code> | ||
'''NOTE:''' The following steps need to be applied to every clone: | '''NOTE:''' The following steps need to be applied to every clone: | ||
Line 26: | Line 26: | ||
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 | 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 | <code><br /> $ scp -p codereview.qt.io:hooks/commit-msg .git/hooks<br /></code> | ||
<br />or by downloading the file via browser: | <br />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). | ||
<br />It is recommended to install the git_post_commit_hook from the | <br />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<br /><code><br />#! /bin/sh<br />exec "<path to git clone>/qtrepotools/git-hooks/git_post_commit_hook" "$</code>"<br /><code><br />into each <path to git clone>it\hooks\post-commit | ||
<br />'''NOTE:''' Starting with git 1.7.8, if | <br />'''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>. | ||
<br />h3. Configuring Git | <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 />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 | ||
Line 35: | Line 35: | ||
<br />to automatically get CRLF line endings which are suitable for the native tools, and Unix users ''should'' use | <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 /></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 | <br />(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, 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: | 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 | </code><br /> $ git config —global user.name "Your Name"<br /> $ git config —global user.email "me<code>example.com"<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. | 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. | ||
Line 45: | Line 45: | ||
To facilitate following the style guide for commit messages, it is recommended to install the Qt commit message template: | 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 | <code><br /> $ git config —global commit.template <path to qt5.git or qt.git>/.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 | 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): | ||
<code><br /> $ git config —global status.showuntrackedfiles all<br /></code> | <code><br /> $ git config —global status.showuntrackedfiles all<br /></code> | ||
Git has a somewhat stupid default that | 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: | ||
<code><br /> $ git config —global push.default tracking<br /></code> | <code><br /> $ git config —global push.default tracking<br /></code> | ||
Line 61: | Line 61: | ||
<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> | <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> | ||
<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: | |||
<code><br /> $ git config —global rebase.stat true<br /></code> | <code><br /> $ git config —global rebase.stat true<br /></code> | ||
To get nicely colored patches (from | To get nicely colored patches (from <code>git diff</code>, <code>git log -p</code>, <code>git show</code>, etc.), use this: | ||
<code><br /> $ git config —global color.ui auto<br /> $ git config —global core.pager | <code><br /> $ git config —global color.ui auto<br /> $ git config —global core.pager "less -FRSX"<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 ;)): | Git supports aliases which you can use to save yourself some typing. For example, these (any similarity with subversion command aliases is purely accidental ;)): | ||
Line 75: | Line 75: | ||
=== Using Existing clones === | === Using Existing clones === | ||
Add a | Add a <code>gerrit</code> remote pointing to codereview. | ||
<code><br /> $ git remote add gerrit ssh://codereview.qt.io/qt/ | <code><br /> $ git remote add gerrit ssh://codereview.qt.io/qt/<qt5 or the submodule name you have checked out><br /></code> | ||
If you are behind a SSH-blocking firewall, use the https protocol: | If you are behind a SSH-blocking firewall, use the https protocol: | ||
<code><br /> $ git remote add gerrit https://codereview.qt.io/p/qt/ | <code><br /> $ git remote add gerrit https://codereview.qt.io/p/qt/<qt5 or the submodule name you have checked out><br /></code> | ||
For Qt 4.8, use | For Qt 4.8, use | ||
Line 93: | Line 93: | ||
=== Cloning repositories === | === Cloning repositories === | ||
You should clone from the repositories hosted at | You should clone from the repositories hosted at "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 ==== | ==== Cloning Qt4 ==== | ||
For | For "qt.gitorious.org":http://qt.gitorious.org/ : | ||
<code><br /> $ git clone git://gitorious.org/qt/qt.git<br /></code> | <code><br /> $ git clone git://gitorious.org/qt/qt.git<br /></code> | ||
For | For "github.com/qtproject":https://github.com/qtproject/ : | ||
<code><br /> $ git clone git://github.com/qtproject/qt.git<br /></code> | <code><br /> $ git clone git://github.com/qtproject/qt.git<br /></code> | ||
Note that Qt4 does not have a | 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 ==== | ==== Cloning Qt5 ==== | ||
For | For "qt.gitorious.org":http://qt.gitorious.org/ : | ||
<code><br /> $ git clone git://gitorious.org/qt/qt5.git<br /></code> | <code><br /> $ git clone git://gitorious.org/qt/qt5.git<br /></code> | ||
For | For "github.com/qtproject":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> | <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> | ||
Line 121: | Line 121: | ||
Alternatively, individual Qt5 submodules can be manually cloned as well. Follow Using Existing Clones above after cloning. | 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 | Note that Qt 5 submodules have been changed from absolute to relative URLs (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/~<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:<br /><code><br />[url | A URL rewrite rule has to be added to the .gitconfig file:<br /><code><br />[url "git://gitorious.org/qt/"]<br /> insteadOf = git://gitorious.org/~<username>/qt/<br /></code> | ||
==== Cloning Qt Creator ==== | ==== Cloning Qt Creator ==== | ||
For | For "qt.gitorious.org":http://qt.gitorious.org/ : | ||
<code><br /> $ git clone git://gitorious.org/qt-creator/qt-creator.git<br /></code> | <code><br /> $ git clone git://gitorious.org/qt-creator/qt-creator.git<br /></code> | ||
For | For "github.com/qtproject":https://github.com/qtproject/ : | ||
<code><br /> $ git clone git://github.com/qtproject/qt-creator.git<br /></code> | <code><br /> $ git clone git://github.com/qtproject/qt-creator.git<br /></code> | ||
Line 137: | Line 137: | ||
=== Pushing your local changes to gerrit === | === Pushing your local changes to gerrit === | ||
After you have committed your changes locally, you can push them to Gerrit like this (for example, | After you have committed your changes locally, you can push them to Gerrit like this (for example, <code>5.4</code> branch): | ||
<code><br /> $ git push gerrit HEAD:refs/for/5.4<br /></code> | <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. | 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". |
Revision as of 13:43, 24 February 2015
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 "Settings" -> "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"-> "SSH Public Keys" and upload your "public SSH Key":https://help.github.com/articles/generating-ssh-keys , configure username (under contact information), upload public "SSH key":https://help.github.com/articles/generating-ssh-keys - If you are behind a firewall that blocks SSH access:
- Go to "Settings" -> "HTTP Password"
- Click "Generate Password"
- Add the following line to your (Windows:
~/.netrc
):%USERPROFILE%netrc
<br />machine codereview.qt.io login <Gerrit username> password <Generated password><br />
h2. Local Setup
Configure SSH properly (the URLs below rely on this). Add this to your
~/.ssh/config
(Windows:
C:USERNAME%sh\config
):
<br /> Host codereview.qt.io<br /> Port 29418<br /> User <Gerrit/Jira username><br />
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
<br /> $ scp -p codereview.qt.io:hooks/commit-msg .git/hooks<br />
or by downloading the file via browser: "commit-msg":http://codereview.qt.io/tools/hooks/commit-msg and putting it into the
.git/hooks
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 Sanity Bot locally. To do this, save the script
<br />#! /bin/sh<br />exec "<path to git clone>/qtrepotools/git-hooks/git_post_commit_hook" "$
"
<br />into each <path to git clone>it\hooks\post-commit
<br />'''NOTE:''' Starting with git 1.7.8, if <code><module name>/.git
contains
gitdir: ../.git/modules/<module name>
, you need to put the submodule hooks in
.git/modules/<module name>/hooks
instead of
<module name>/.git/hooks
.
h3. 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
$ git config —global core.autocrlf true
<br />to automatically get CRLF line endings which are suitable for the native tools, and Unix users ''should'' use
<br />
$ git config —global core.autocrlf input
<br />(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, 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:
$ git config —global user.name "Your Name"
$ git config —global user.email "me
example.com"<br />
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 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:
<br /> $ git config —global commit.template <path to qt5.git or qt.git>/.commit-template<br />
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
git stat
and
git commit
, even if this is somewhat slower (especially on Windows):
<br /> $ git config —global status.showuntrackedfiles all<br />
Git has a somewhat stupid default that
git push
will push all branches to the upstream repository, which is almost never what you want. To fix this, use:
<br /> $ git config —global push.default tracking<br />
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:
<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 />
git pull
will show a nice diffstat, so you get an overview of the changes from upstream.
git pull —rebase
does not do that by default. But you want it:
<br /> $ git config —global rebase.stat true<br />
To get nicely colored patches (from
git diff
,
git log -p
,
git show
, etc.), use this:
<br /> $ git config —global color.ui auto<br /> $ git config —global core.pager "less -FRSX"<br />
Git supports aliases which you can use to save yourself some typing. For example, these (any similarity with subversion command aliases is purely accidental ;)):
<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 />
Using Existing clones
Add a
gerrit
remote pointing to codereview.
<br /> $ git remote add gerrit ssh://codereview.qt.io/qt/<qt5 or the submodule name you have checked out><br />
If you are behind a SSH-blocking firewall, use the https protocol:
<br /> $ git remote add gerrit https://codereview.qt.io/p/qt/<qt5 or the submodule name you have checked out><br />
For Qt 4.8, use
<br /> $ git remote add gerrit ssh://codereview.qt.io/qt/qt<br />
If you are behind a SSH-blocking firewall, use the https protocol:
<br /> $ git remote add gerrit https://codereview.qt.io/p/qt/qt<br />
Cloning repositories
You should clone from the repositories hosted at "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/ :
<br /> $ git clone git://gitorious.org/qt/qt.git<br />
For "github.com/qtproject":https://github.com/qtproject/ :
<br /> $ git clone git://github.com/qtproject/qt.git<br />
Note that Qt4 does not have a
master
branch (since no 4.9 is planned). So, you should push changes to the
4.8
branch.
Cloning Qt5
For "qt.gitorious.org":http://qt.gitorious.org/ :
<br /> $ git clone git://gitorious.org/qt/qt5.git<br />
For "github.com/qtproject":https://github.com/qtproject/ :
<br /> $ git clone git://github.com/qtproject/qt5.git<br /> $ cd qt5<br /> $ ./init-repository -f —no-webkit —mirror git://github.com/qtproject<br />
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 "../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:
<br />[url "git://gitorious.org/qt/"]<br /> insteadOf = git://gitorious.org/~<username>/qt/<br />
Cloning Qt Creator
For "qt.gitorious.org":http://qt.gitorious.org/ :
<br /> $ git clone git://gitorious.org/qt-creator/qt-creator.git<br />
For "github.com/qtproject":https://github.com/qtproject/ :
<br /> $ git clone git://github.com/qtproject/qt-creator.git<br />
Pushing your local changes to gerrit
After you have committed your changes locally, you can push them to Gerrit like this (for example,
5.4
branch):
<br /> $ git push gerrit HEAD:refs/for/5.4<br />
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".