Gerrit/git-review/fr

git-review est un outil en mode ligne de commande pour Git /  permettant de soumettre une modification, ou de récupérer une modification existante.

Notez que Wikimedia Gerrit nécessite la version 1.27 ou supérieure de git-review.

La branche principale du projet est gérée par OpenStack. A ne pas confondre avec le projet Facebook qui est indépendant.

Installation

 * Voir aussi : tutoriel Gerrit

Après avoir installé Git (1, 2), créé un compte utilisateur Gerrit, créé une clé ssh (3, 4), et cloné le dépôt de votre projet (ou celui de l'exemple), vous êtes prêt à installer git-review, un outil pour travailler avec les dépôts Gerrit qui vous évite de mémoriser certaines commandes. Suivez les instructions ci-dessous en fonction de votre système d'exploitation, et n'oubliez pas de le configurer ensuite !

Debian/Ubuntu/Mint
Les utilisateurs de Debian ou des distributions associées (telles que Ubuntu, Mint) sur un hôte partagé n'ont habituellement pas l'accès root. Si l'administrateur de votre site d'hébergement ne peut pas vous installer git-review, vous pouvez essayer de le faire localement. Allez à la section correspondante ci-dessous

Avec l'accès root
Vous pouvez faire :

ou :

Si vous ne disposez pas de easy_install, essayez

Si vous n'avez pas  mais que   est installé, vous pouvez utiliser ceci; voir plus loin pour les instructions particulières pour OS X.

si vous avez Ubuntu 20.04, essayez :

Puis exécutez :

dans votre copie clonée, pour configurer votre environnement de travail Gerrit. On vous demandera probablement votre nom d'utilisateur pour la validation. L'accroche commit-msg sera ensuite automatiquement installée.

Sans l'accès root
Si vous êtes sur un hôte partagé et que votre système n'a pas git-review, vous pouvez l'installer localement dans votre répertoire utilisateur.

Si ceci est votre première installation locale, ou si vous ne l'avez jamais fait, mettez à jour votre variable d'environnement PATH pour prendre en compte les binaires locaux. Il y a deux manières de faire cela. La manière la plus conservative :

lets the system look through all binary directories first, and only looks into the local binary directory if a command was not found elsewhere. If you want software installed locally in your home directory to override system programs, you need the inverse the sort order.

Vous avez peut-être déja fait cela plus tôt. You may want to add either command to your login sequence to have it run automatically.

If you do not want to alter your PATH variable, you don't have to. In this case, you cannot use the command  but must remember to use   instead.

Exécutez enfin :

or

respectivement, dans votre copie clonée pour le configurer afin qu'il fonctionne avec Gerrit. On vous demandera probablement votre nom d'utilisateur pour la validation. L'accroche commit-msg sera ensuite automatiquement installée.

Fedora≤21/CentOS
Si pendant l'utilisation de git-review vous voyez, vous devrez installer   :

Il est possible que yum ne trouve pas le paquet git-review -- dans ce cas vous pouvez autoriser le répertoire EPEL et recommencer.

OpenSUSE
Installez (YaST) le, ensuite :



Depuis OpenSUSE 13.1, git-review se trouve dans le dépôt principal, vous pouvez donc utiliser

Instable
Si vous utilisez la branche instable de nixpkgs, git-review est disponible en tant que paquet. Installez avec :

nix-env -i python2.7-git-review

Anciennes branches de nixpkgs
Installez python et pip :

nix-env -i -A pythonPackages.pip Ajouter ~/.local/bin à votre chemin :

export PATH=$PATH:~/.local/bin echo 'export PATH=$PATH:~/.local/bin' >> ~/.bashrc

Installez git-review :

pip install git-review --user pip install --upgrade setuptools pip install --upgrade distribute

Installation avec l'installateur du paquet Python pip
Note: if you don't have  but have   installed, you can also install the latest version of git-review by using the python package installer. The exact command depends on your distribution, either or

Once  is installed, you can

FreeBSD
You can directly install git-review through ports.

Windows
Python is needed for git-review to function and pip is used for its installation:
 * Install Python or upgrade to the most current version of Python 2 or Python 3.
 * Important: Do not install Python in any directory with a space in its path as there is a pip bug (see ), use the default, e.g.
 * During the Python installation, manually select Add python.exe to Path
 * Otherwise, add your python scripts directory manually to the system path (Settings, Control panel, System, Advanced system settings, Environment variables, User variables, Path; e.g. ). Different directories in path are delimited by a semicolon ";" only - do not add any whitespace to path list.)
 * Python 3.4 has pip already installed. Only if you have an older version, install pip by following the instructions here.
 * Run Git Bash as Administrator (right click on icon for this option) and install git-review with the following command:
 * pip install git-review
 * If you experience problems such as these:
 * Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/git-review/
 * try running:
 * pip install git-review --proxy=www-proxy-lon.uk.oracle.com:80
 * the exact proxy to use can be extracted from http://wpad/wpad.dat file.


 * To use, you have to be in a git clone directory that already contains a (possibly hidden)   configuration file (see Gerrit/Advanced usage)

Méthode 1 (Homebrew)
Works on OS X 10.11 El Capitan and later (verified on High Sierra 10.13.5):


 * 1) Install Homebrew
 * 2) Install git-review with

Méthode 2 (paquet Python de l'installateur pip)
Mac OS X comes with Python 2.7 (for now) but not the installation programs supported by Git and git-review.


 * 1) Open Terminal and change to a directory you're comfortable downloading test Git packages to (such as Downloads)
 * 2) Download and install the OS X Installer for Git (for OS X 10.8 and earlier only, OS X 10.9 ships with Git pre-installed)
 * 3) Install pip (Note: Already included in some older versions of OS X):
 * 4) Update pip/setuptools (for OS X 10.7 and earlier only)
 * 5) Install git-review.  OS X as of version "El Capitan" protects locations in the filesystem including   so typical  install method will fail using sudo. Instead install git-review locally to your home folder like this:
 * 6) Update your PATH shell variable to include the location of git-review which should be in

If you get the error, you may want to try nuking the pre-installed Python (/Library/Python/), installing Python via homebrew , and re-installing setuptools and git-review.

If you get a  after a seemingly successful installation, do not reinstall over the existing installation, but uninstall git-review and redo

Configurer git-review
Follow the instructions in the Gerrit tutorial to configure git-review so that it uses "origin" as its default remote. This avoids confusion and conflicts between remotes named "gerrit" and "origin".

After cloning a repository, you need to set it up for using git-review. This will automatically happen the first time you try to submit a commit, but it's generally better to do it right after cloning.

This may ask you for your git username, if it's different from the shell username you're using.

Internally, this does the following:
 * checks whether accessing the remote repository works
 * if it doesn't, asks for a username and tries again
 * creates a remote called 'gerrit' that points to gerrit
 * installs the commit-msg hook

Publier les modifications avec git-review
Submitting changes with git review does not involve a lot of commands: git checkout -b mycoolfeature change files git commit -a git review

Ce qui se passe quand vous publiez vos modifications
When you submit a change, git review does the following things:
 * it looks up which branch to push to (production or whatever) in the .gitreview file. If it can't find this information, it pushes to master
 * it figures out what "topic" to put on the revision (you can set the topic manually with )
 * if you're resubmitting a downloaded change, it will reuse the topic of the original change
 * if your commit summary contains a bug number like, the topic will be
 * otherwise, the topic will be the name of your local branch
 * it rebases your change against the HEAD of the branch you're pushing to (use  to skip this)
 * if you are submitting more than one change at once, or submitting a change that's based on another unmerged change, it will ask you whether you really meant to do that (use  to skip this)
 * it pushes the change for review

Downloading a change with git-review
When downloading a change from gerrit to review it or amend it, git-review offers an alternative to copy-pasting a magic incantation from the Gerrit web UI. All you need is the sequence number of the change in Gerrit, which you can find in the URL:. git review -d 2033 This will download the change, put it in a branch called  (if the change has no tag, the sequence number will be used instead), and switch to that branch.

After that, you can amend the downloaded change to improve it.

Troubleshooting
For problems and how to solve them, see Gerrit/Troubleshooting.

Troubleshooting for Windows
If this fails, you have a couple of options. The first is the use scp (secure copy) from within your local repository's directory, for each repository, before committing edits to it:

scp -P 29418 USERNAME@gerrit.wikimedia.org:hooks/commit-msg .git/hooks/commit-msg

The second is to try patching  to make git-review work properly:

If using Python 2.x and git-review 1.17 or earlier, use  instead of.

Another error encountered on Windows is: ...   (top_dir, git_dir) = git_directories ValueError: too many values to unpack (expected 2)

One solution to this is to change the return line of  to use splitlines rather than its normal split function. Split looks for any whitespace and will produce this error when the path to your source code directory contains a space. Splitlines looks for newline characters and will not produce this same error.