Help:Toolforge/Version Control in Toolforge

From Wikitech
Jump to navigation Jump to search

Overview

This page covers version or source control and code review tools to help users manage files in Toolforge.

What you'll need

Basic understanding of:

  • Git
  • Version or source control
  • Code review

Version control and code review for Toolforge

Code can be edited manually in the Tool Account directory, but we recommend that you use version control or source control and code review tools.

There are several benefits to doing this:

  1. You will have backups and control over any irreplaceable data.
  2. You will be able to track changes to your project over time.
  3. You will have an easier time collaborating with other tool maintainers working on the same Tool Account.

Git

Git is a popular version control system used by many software developers.

Tool Account collaborators use Git repositories track changes to files.

For more information about using Git, please see the git documentation.

Setting up repositories

Diffusion

Diffusion is a Phabricator repository browser and repository management tool. Diffusion can host repositories locally, or observe existing remote repositories which are hosted elsewhere.

To create a Diffusion repository for your Tool Account:

  1. Go to toolsadmin
  2. Find your tool
  3. Click the create new repository button

See the Diffusion User Guide for more documentation.

Gerrit

Gerrit is a code collaboration tool that integrates with Git.

Gerrit is used across Wikimedia technical projects. If you collaborate on tools using Toolforge you will want to be familiar with Gerrit. Gerrit supports code review and git repositories can be accessed via SSH. Learn more about using Gerrit on mediawiki.org.

Request a Gerrit repository for your tool

To use the Wikimedia Cloud VPS code review and version control, you must upload your SSH key to Gerrit and then request a Gerrit repository for your tool.

  1. Log in to https://gerrit.wikimedia.org/ with your Wikimedia developer account username and password.
  2. Add your SSH public key (select “Settings” from the drop-down menu beside your user name in the upper right corner of the screen, and then “SSH Public Keys” from the Settings menu).
  3. Request a Gerrit project for your tool: Gerrit/New repositories

For more information about using Git and Gerrit in general, please see Git/Gerrit.

Github, Gitlab, Bitbucket, and other Git repositories

Before you start, setup your Git user account. Login to your tool account

$ become mytool

Then you can clone the remote repository:

$ git clone https://github.com/yourGithubName/yourGithubRepoName.git

Local Git repository

You can set up a local Git repository to keep backups of versions of your code.

To create a local Git repository:

1. Create an empty Git repository

maintainer@tools-login:~$ git init

2. Add the files you would like to backup. For example:

maintainer@tools-login:~$ git add public_html

3. Commit the added files

git commit -m 'Initial check-in'

Enable simple public HTTP access to local Git repository

If you've set up a local Git repository in your Tool Account directory, you can set up public read access to the repository through HTTP.

This will allow you to clone the Git repository to your own home computer without using another service.

1. Create the www/static/ subdirectory in your tool's home directory:

mkdir ~/www
mkdir ~/www/static/

2. Go to the www/static/ directory. Make a symbolic link to your bare Git repository (the hidden .git subdirectory in the root of your repository):

cd ~/www/static/
ln -s ~/.git yourtool.git

3. Change the directory into the symbolic link. Run the git update-server-info command to generate auxiliary info files needed for the HTTP connectivity:

cd yourtool.git
git update-server-info

4. Enable Git hooks for updating the auxiliary info files every time someone commits, rewrites or pushes to the repository:

ln -s hooks/post-update.sample hooks/post-commit
ln -s hooks/post-update.sample hooks/post-rewrite
ln -s hooks/post-update.sample hooks/post-update
chmod a+x hooks/post-update.sample

You should be able to clone the repository from any remote machine by running the command:

git clone http://tools-static.wmflabs.org/yourtool/yourtool.git

Communication and support

We communicate and provide support through several primary channels. Please reach out with questions and to join the conversation.

Communicate with us
Connect Best for
Phabricator Workboard #Cloud-Services Task tracking and bug reporting
IRC Channel #wikimedia-cloud connect General discussion and support
Mailing List cloud@ Information about ongoing initiatives, general discussion and support
Announcement emails cloud-announce@ Information about critical changes (all messages mirrored to cloud@)
News wiki page News Information about major near-term plans
Blog Clouds & Unicorns Learning more details about some of our work

See Also

Help:Toolforge