手册:Pywikibot/Gerrit

This page is a translated version of the page Manual:Pywikibot/Gerrit and the translation is 26% complete.
Outdated translations are marked like this.

术语

对于用户

Git客户端

Windows用户:我们建议您使用TortoiseGitGit for Windows。 建议先安装TortoiseGit

macOS / Linux:命令行git

- https://git-scm.com/ or brew install git(Homebrew, macOS)
例如,通过命令行下载核心包:

$ git clone --recursive --branch stable https://gerrit.wikimedia.org/r/pywikibot/core.git

更新:

# Assuming you're already in "core":
$ git pull origin stable
$ git submodule update # Updates i18n messages

如果你很懒,希望能够一次性做到这一点,你可以这样做:

# Assuming you're already in "core":
$ git pull origin stable --recurse-submodules # This updates everything

Note that the repositories are somewhat large (>100MB). If this is an issue, use

$ git clone --recursive --branch stable --depth 3 https://gerrit.wikimedia.org/r/pywikibot/core.git

to just retrieve the latest versions.


使用SVN

但是等等... 我不想使用Git。 我还能使用SVN吗?是! 但是别忘了单独配置和更新i18n子模块。

$ svn co https://github.com/wikimedia/pywikibot/tags/stable
$ cd stable/scripts
$ svn co https://github.com/wikimedia/pywikibot-i18n/trunk i18n

Updating is as simple as

$ svn up stable
$ cd stable/scripts
$ svn up i18n
Windows users may also use the GUI extension TortoiseSVN. 您可以在这里找到相关文档。

链接

您的客户端可能会要求您提供存储库URL。 网址遵循以下格式: https://gerrit.wikimedia.org/r/pywikibot/[repo name].

So for core:

https://gerrit.wikimedia.org/r/pywikibot/core.

Nightly distributions

You can download the whole packages or browse the source code via download page in Wikimedia Forge


If you need more help on setting up your Pywikibot visit the #pywikibot IRC channel connect or pywikibot@ mailing list.


For developers

How to submit patches...configure git/gerrit. etc.

Read the guidelines, then follow steps in Gerrit/Getting started and run this:

#for hacking core
$ git clone --recursive ssh://USERNAME@gerrit.wikimedia.org:29418/pywikibot/core.git

and after modifying codes follow steps in Gerrit/教程

Windows
Developer using Windows may also use Gerrit/TortoiseGit tutorial for further informations.

Example (step-by-step)

Do the following, step-by-step:

    1. if not done already for svn access; create an SSH key, a developer account and add your public key to gerrit as well as to wikitech
    1. install 'git' package
    1. install 'git-review' package
      • the one by openstack [1], NOT the one by Facebook
      • any version like 1.12, 1.21, but NOT v1.18
  1. clone and setup your repository:
    1. clone the git repository with all submodules by using (like svn checkout)
      $ git clone --recursive ssh://USERNAME@gerrit.wikimedia.org:29418/pywikibot/core.git pywikibot-git
      
      and wait, this step will take some time
    1. enter the directory
$ cd pywikibot-git
    1. config git setting for this repository/directory only (not global, in case e.g. you have different pseudo for multiple projects)
      $ git config user.email "EMAIL"
      
      and
      $ git config user.name "USERNAME"
      
      in order to configure this globally, use the --global parameter
    1. config your terminal/console to output english messages (in order to work properly with git review, see Gerrit/git-review#Troubleshooting)
$ alias git="LANG=C git"

this has to be done every time a new console is started, in order to configure this permanently, put this into your bashrc or similar setup file

    1. setup git review for this repository only
$ git review -s

and enter your USERNAME again, this is an important step - if you forget it, according to Gerrit/Tutorial#Push your change set to Gerrit, the final git review below (needed to commit your changes for review) will fail - though this can be still solved then

  1. work with the repository, e.g. commit patches for review:
    1. switch to the master branch (might not be needed)
$ git checkout master
    1. update the current branch to revision online (like svn update)
$ git pull
    1. create your own local temporary branch for working $ git checkout -b MEANINGFUL_BRANCH_NAME and try to choose a MEANINGFUL_BRANCH_NAME with the help of the branch naming tips available – the branch can be removed when not needed anymore with $ git branch -D MEANINGFUL_BRANCH_NAME
    1. now write some code; see the Git commands add, rm and mv to add, remove or rename files - when you're ready go to the next step
    1. commit your changes to your local temporary branch with
      $ git commit --all
      
      (you can use -a instead of --all and -R instead of --no-rebase) and, as used from svn, enter a meaningful commit message, e.g. a short description of your code changes
    1. optionally check your changes by looking at the committed data
      $ git show HEAD
      
      and make sure that you are sending what you wanted to
    1. send the data to the online repository, resp. gerrit for review (like svn commit)
      $ git review
      
    1. finally go to Gerrit, click on your change and write a reviewer name in the input box near the "Add Reviewer" button
  1. optionally/opt-in further settings:
    • enable RCS keywords expansion (like svn:keywords $Id$) by using git hooks (explained in detail here - german only)

Phabricator

Patches will be linked to a Phabricator task automatically if you mention 'Bug: T12345' in a line just before 'Change-Id: ....'. See Gerrit/提交消息指引 for more information.

Problems, issues and work-a-rounds

jenkins-bot messages

https://integration.wikimedia.org/ci/job/pywikibot-core-tox-flake8/2591/console : FAILURE in ?s (non-voting)

The patchset committed did not pass flake8 code style checks. That says nothing about the functionality of the code but about the syntax and style.

https://integration.wikimedia.org/ci/job/pywikibot-core-tox-flake8-docstrings-mandatory/560/console : FAILURE in ?s (non-voting)

The patchset committed did not pass mandatory pep257 code style checks. That says nothing about the functionality of the code but about the inline documentation.

https://integration.wikimedia.org/ci/job/pywikibot-core-tox-nose/1448/console : FAILURE in ?s (non-voting)

The patchset committed did not pass pre-merge test suite. That indicates the code fails the basic tests, but a pass says nothing about the functionality of the modified code. There is a more extensive set of tests which developers should run pre-submission, and will run post merge.

This change could not be automatically merged with the current state of the repository. Please rebase your change and upload a new patchset.

The pachset cannot be merged automatically into current HEAD. Please consider Build failed due to merge conflict for a solution.